Creating bookmarked PDF from Mapbook (Python) export script

I regularly use an export script to create multi-page PDFs from Data-Driven-Pages based Map-books. I am able to export and append each individual page to the PDF, and save the PDF in the single-page layout with the “Page Thumbnails” pane opened. I need to be able to (Pythonically) set the Bookmark text for each page within the PDF. I can do this manually from Adobe, but it would save a lot of time and headache if it could be automated.

Here is the script I use, at its most basic level without any bells or whistles. At the bottom of the script is where I set the page-layout (pdf_open_view="USE_THUMBS"). I can use "USE_BOOKMARKS" but this doesn’t actually apply any bookmark text to the individual pages.

import arcpy, os
mxdPath = r"C:tempMyMapBook.mxd" 
tempMap = arcpy.mapping.MapDocument(mxdPath)
tempDDP = tempMap.dataDrivenPages

outDir      = r"C:temp"   #PDF Folder where the individual pages and Combo are created
comboPDF    = r"MultiPage_PDF.pdf"        #Name of Combo PDF
finalpdf_filename = os.path.join(outDir + comboPDF)
finalPdf = arcpy.mapping.PDFDocumentCreate(finalpdf_filename)

for pgIndex in range(1, tempDDP.pageCount + 1):
    tempDDP.currentPageID = pgIndex
    figName = str(tempDDP.pageRow.sdsFeatureName)
    figNumber = str(tempDDP.pageRow.Fig_Num_2015FSP)
    pageName = "Page-" + figNumber + "_" + figName + ".pdf"
    individualPagePDF = os.path.join(outDir + "\" + pageName)

    #do something to the page before exporting. e.g. add inset map, add table etc.

    ###################################################################
    tempDDP.exportToPDF(individualPagePDF, "CURRENT") # export to signle page PDF
    finalPdf.appendPages(individualPagePDF) # append the page to the "combo" PDF
    print pageName + " added to final mapbook pdf"                    
    ###################################################################

    #undo whatever page modifications you just did before the export

##### Delete Objects
del tempMap, tempDDP

finalPdf.updateDocProperties(pdf_open_view="USE_THUMBS",pdf_layout="SINGLE_PAGE")
finalPdf.saveAndClose()

Creating Layer objects in ArcGIS Pro?

I’m having difficulty with the Make Feature Layer examples.

I’m importing arcpy from a standalone script using the “c:Program FilesArcGISProbinPythonscriptsproenv.bat” provided by ESRI. This activates the environment, then I use:

(arcgispro-py3) > python test.py

to run it. There are no issues importing arcpy and I get the same error if I try the script with ArcGIS Pro running, and with ‘use offline’ enabled. I do not think this is a license authentication issue or arcpy would not import.

In their docs example, it is possible to set the workspace and then pass a shapefile inside that workspace to the MakeFeatureLayer_management function. When I try this in a minimal script I get an unhelpful error message.

import arcpy
print(arcpy.GetInstallInfo())
ws = 'C:\Users\myself\testing\test_query_bboxes'
fc = 'test_bboxes.shp'

arcpy.env.workspace = ws
arcpy.MakeFeatureLayer_management(fc, 'test_lyr')

{'InstallDir': 'c:\program files\arcgis\pro\',  
'Installer': 'myself',  
'ProductName': 'ArcGISPro',  
'Version': '2.2.4',  
'SourceDir': 'C:\Users\myself\Documents\ArcGIS Pro 2.2\ArcGISPro\',  
'InstallType': 'N/A',  
'BuildNumber': '12813',  
'InstallDate': '11/7/2018',  
'InstallTime': '12:51:07',  
'SPNumber': 'N/A',  
'SPBuild': 'N/A'}

RuntimeError Traceback (most recent call last)
 in ()
 5 
 6 arcpy.env.workspace = gdb
----> 7 arcpy.MakeFeatureLayer_management(fc, 'test_lyr')

C:Program FilesArcGISProResourcesArcPyarcpymanagement.py in MakeFeatureLayer(in_features, out_layer, where_clause, workspace, field_info)
 6532 return retval
 6533 except Exception as e:
-> 6534 raise e
 6535 
 6536 @gptooldoc('MakeImageServerLayer_management', None)

C:Program FilesArcGISProResourcesArcPyarcpymanagement.py in MakeFeatureLayer(in_features, out_layer, where_clause, workspace, field_info)
 6529 from arcpy.arcobjects.arcobjectconversion import convertArcObjectToPythonObject
 6530 try:
-> 6531 retval = convertArcObjectToPythonObject(gp.MakeFeatureLayer_management(*gp_fixargs((in_features, out_layer, where_clause, workspace, field_info), True)))
 6532 return retval
 6533 except Exception as e:

C:Program FilesArcGISProResourcesArcPyarcpygeoprocessing_base.py in (*args)
 494 val = getattr(self._gp, attr)
 495 if callable(val):
--> 496 return lambda *args: val(*gp_fixargs(args, True))
 497 else:
 498 return convertArcObjectToPythonObject(val)

RuntimeError: Object: Error in executing tool

To be clear, this function works as expected with the arcpy from ArcMap 10.6 for both compete paths to the input featureclass (both in geodatabases an as shapefiles) and as names within the workspace.

What am I missing about how to initialize a Layer object in arcpy from ArcGIS Pro 2.2.4?

ffmpeg creating a boomerrang video

I’m trying to use ffmpeg to create a “boomerrang” video. Where it would take in one video, play that video forward, then play it backward, and once more forward all at 1.5x speed. I’m been able to do the forward/backwards process with this command:

ffmpeg -y -i input.mp4 -filter_complex [0]reverse[r];[0][r]concat,setpts=0.5*PTS output/boomerrang.mp4

But I’ve been unable to get that final 3rd play with the video playing forward. I’m assuming I would just need to concat the video on the end but I’m not really sure how to do that.

How would you go about creating distorted textures like in Olga Bell’s Music Video ATA?

I am guessing this is a basic question, but since I am fairly new to blender, I`d be happy for some help:

How would I go about texturing an abstract shape with a photograph so that from a certain vantage-point the texture reveals the original photograph?
The idea comes from Olga Bell`s video ATA

Here are some images:
enter image description here
enter image description here

I have completed a lesson on color displacement which results in a blend that has the same vantage point effect, but follows different principles.

Thanks for your help!

Error creating Scratch Org – The Streaming request failed to handshake

I’m trying to create a scratch org using either VS Code or the command line. I’m able authenticate to my dev org using:

sfdx force:auth:web:login

This works correctly. However when I try to create a scratch org:

sfdx force:org:create -f configproject-scratch-def.json --setalias HelloWorld --setdefaultusername

I get the following error:

ERROR:  The streaming request failed to handshake at https://.my.salesforce.com/cometd/44.0.

I am behind a corporate proxy and initially could not even authenticate my dev org until I set the proxy environment variables and their npm equivalents. I also currently have sslVerify and strict-ssl set to false. Please let me know if there is any additional information I need to give. Thanks!

Michael

Subversion with reverse proxy causing issues while creating new branch from trunk

we have recently installed subversion with reverse proxy (nginx). While creating a new branch from the trunk, we are getting the below error.

Any help on this would be appreciated.

Nginx Configuration:

server {
        client_max_body_size 40M;
        listen 443 default ssl;
        server_name msg.jdstg.com;
        ssl_certificate /etc/nginx/ssl/tlscert.crt;
        ssl_certificate_key /etc/nginx/ssl/private.key;

       location /repos/ {
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Host $http_host;
                proxy_set_header X-NginX-Proxy true;
                proxy_pass http://127.0.0.1:80;
                proxy_redirect off;
       }
}

enter image description here

Creating materialized view is very slow

I have quite a complex query in PostgreSQL 10.4 on Amazon RDS (3 joins, quite a few conditions). It takes from 1.5 to 6 seconds to perform a select. However, when I want to create a materialized view from it to speed it up, it takes forever. By forever I mean more that 30 minutes (usually after this client drops connection or something).

Now, I understand that SELECTs make extensive use of parallelization to speed things up and when there is a write (as in creating a materialized view) it cannot use it, but should the results be that different (couple of seconds vs >30 minutes)?

Here’s the query in question:

SELECT 
  [...]
FROM 
  "profiles" 
  LEFT OUTER JOIN (
    SELECT DISTINCT "member_id" AS "cpn_member_id" 
    FROM  "coupon_collections" 
    WHERE  (("seen" >= '2017-11-02 14:15:43.111597+0000') AND ("seen" <= '2018-11-02 14:15:43.111652+0000')) 
    GROUP BY "member_id"
  ) AS "ex1" ON ("ex1"."cpn_member_id" = "profiles"."member_id") 
  LEFT OUTER JOIN "mobile_data" ON (
    "mobile_data"."member_id" = "profiles"."member_id"
  ) 
  LEFT OUTER JOIN "consents" AS "consents_sms_marketing" 
    ON (("consents_sms_marketing"."member_id" = "profiles"."member_id") 
      AND ("consents_sms_marketing"."name" = 'sms_marketing')) 
WHERE 
  (("community_id" = 1058) AND (("push_enabled" IS FALSE) OR ("push_token" IS NULL)) 
    AND ("profiles"."optin_date" :: date >= '2012-01-01T00:00:00+01:00' :: date) 
    AND ("profiles"."optin_date" :: date <= '2018-09-30T00:00:00+02:00' :: date) 
    AND ("ex1"."cpn_member_id" IS NULL)
    AND ("profiles"."msisdn" IS NOT NULL) 
    AND ("data" ->> 'user_status') = 'verified') 
    AND ("consents_sms_marketing"."value" IS TRUE) 
  )

Unfortunately, I’m not able to run explain analyze, because query never ends. Using simply explain, I see the same plan with only difference that SELECT shows planned use of 2 parallel workers and CREATE MATERIALIZED VIEW does not.

Creating raw transactions for sending ERC721 tokens

I was able to create raw transactions for eth following this article https://medium.com/blockchain-musings/how-to-create-raw-transactions-in-ethereum-part-1-1df91abdba7c

However, how can I create raw transactions when send ERC721 tokens? More specifically, where do I add the token id field when creating raw transactions?

Creating gridded mesh of lat-long using R?

I have a csv file containing lat-long and corresponding land cover classification (LCC) data as shown below:

Longitude  Latitude   LCC
    50.01     30.1    110
    70.02     20.8    110
    60.08     30.5    110
    86.04     50.4    110
    .
    .
    .
    90.06    20.7    120
    70.07    50.6    120
    70.08    30.5    120     
    64.04    30.9    120
    .
    .
    .

Each LCC has a unique RGB value (0,255). For example, say LCC 110 has (125,255,0). I need to create 3 separate excel files each containing R, G and B values in the following form:

220 220 220 220 200 100 100 0 0 120 250 . . . 
100  50 105 102  70 200 100 110 110  50 . . . 
210 105 100 100 220 200 100 0 0 120 200 . . .
. . . 
. . .

So here in first row first column, the 220 corresponds to the R value of the LCC 110 and the place value corresponds to lat-long (30.1,50.01).
Similarly, two more files of G and B bands.

How do I convert the lat-log column into a gridded structure using R?