|
POST
|
Thanks Darren, This will work perfectly. I'll post my code once I've completed for everyone else to see what I was trying to achieve.
... View more
11-23-2016
10:04 PM
|
0
|
0
|
1060
|
|
POST
|
I'm creating a list of feature class with lists of stats of each feature class to identify duplicate feature classes so that I can drop the rest and only copy one over to the a new directory. The items in the list that I'm using to identify uniqueness is file name; number of records in feature class; area (sqm) of minimum bounding# geometry. The file path with file name is also added but a sub list is returned for testing if the values exist within the final list of unique feature classes. for each feature class: append a list into an existing list made up of file path, file name, number records, area of minimum bounding geometry. before adding the next feature class test whether the sub list [file name, number records, area minimum bounding geometry] don't already exist within the list of lists as a sublist (i.e. minus the file path) to prevent duplicate feature classes from being added to the list of lists of feature classes. I've tried using Python built in functions any and all with no luck. cont_list = [] for fc in focus: stats_list = 1 stats_list = 2 cont_list.append(stats_list) if stats_list[1:] in cont_list: print("exists") else: cont_list.append(stats_list) note: all values in stats_list[1:] must match in list of list to be seen as a match to match duplicates. Any advice in how to achieve this will be appreciated.
... View more
11-23-2016
03:12 PM
|
0
|
5
|
4712
|
|
POST
|
I've created a python script that I've published as a geoprocessing service. The python script takes as input an SGID, a unique id associated with a land parcel, landuse indicating crop fields irrigated and non-irrigated. The map is exported to a jpeg image for each SGID supplied to the python script. I've added arcpy.SetParameter(3, output_jpeg) at line 52 to return the output jpeg to the geoprocessing service. '''
Created on 12 Sep 2016
Generate a JPEG
for a land parcel
indicating the irrigation
status based on SGID
@author: PeterW
'''
# import site-packages and modules
import math
import arcpy
# set arguments
input_sgid = arcpy.GetParameterAsText(0)
input_mxd = arcpy.GetParameterAsText(1)
output_folder = arcpy.GetParameterAsText(2)
# set environment settings
arcpy.env.overwriteOutput = True
# function to export map document to jpeg based on sgid
def vandv_ddp_jpegs(input_mxd, input_sgid, output_folder):
""" export map document to jpeg based on sgid """
mxd = arcpy.mapping.MapDocument(input_mxd)
df = arcpy.mapping.ListDataFrames(mxd)[0]
lyrs = arcpy.mapping.ListLayers(mxd, "", df)
elm_title = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "sgkey")[0]
try:
sqlquery = "{0} = {1}".format("SGID", input_sgid)
arcpy.MakeFeatureLayer_management(lyrs[0], "Cadastre_lyr", sqlquery)
with arcpy.da.SearchCursor("Cadastre_lyr", ["SGID", "ID", "SHAPE@"]) as scur1: # @UndefinedVariable
for row in scur1:
elm_title.text = row[1]
SGID = row[0]
def_query1 = "{0} = {1}".format("SGID", SGID)
lyrs[0].definitionQuery = def_query1
lyrs[1].definitionQuery = def_query1
df.extent = row[2].extent
df.scale = int(math.ceil(df.scale/5000)*5000)
arcpy.RefreshActiveView()
output_jpeg = "{0}\\{1}.jpg".format(output_folder, SGID)
arcpy.AddMessage("Exporting SGID {0} jpeg".format(SGID))
arcpy.mapping.ExportToJPEG(mxd, output_jpeg, resolution=150)
lyrs[0].definitionQuery = ""
lyrs[1].definitionQuery = ""
arcpy.SetParameter(3, output_jpeg)
except arcpy.ExecuteError:
print(arcpy.GetMessages(2))
vandv_ddp_jpegs(input_mxd, input_sgid, output_folder)
Within the ArcToolbox parameter settings, I've set the output parameter Output JPEG as a Raster Dataset Data Type and Parameter Type as Derived and Output. I then ran the python script locally, in order to publish the result as a geoprocessing service. I copied the REST URL: http://172.16.1.16:6080/arcgis/rest/services/Geoprocessing_VandV/ExportToJPEG/GPServer into my browser in order to execute it. The output raster returned is renamed adding "_ags_" prefix, and saved out as TIFF format. and if I rerun the geoprocessing service for the same SGID, it doesn't overwrite the raster but adds a suffix "1". {
"results": [{
"paramName": "Output_JPEG",
"dataType": "GPRasterDataLayer",
"value": {
"url": "http://172.16.1.16:6080/arcgis/rest/directories/arcgisoutput/Geoprocessing_VandV/ExportToJPEG_GPServer/_ags_935814.tif",
"format": "tif"
}
Is there a way to prevent this from happening. I need the raster to be jpeg's not tiff's and the name cant' be changed it needs to match the SGID. The rasters also need to be overwritten if they exist as the data is constantly being updated so the jpegs need to reflect the updates each time they are rerun as they are being imbeded into a SSRS report that is being sent out to the owners of the land parcels. I've tried saving the output as a string rather, but unfortunately the path is not returned as a URL but as an absolute path that can't be used by the SSRS report request. Any help will be appreciated. Python ; Geoprocessing ; ArcGIS for Server ; https://community.esri.com/community/developers/web-developers/arcgis-rest-api
... View more
11-15-2016
09:36 AM
|
1
|
0
|
1300
|
|
POST
|
I need to publish my python script as a geoprocessing service, which I've never done before. The geoprocessing service needs to take as input the SSRS Url, extract the SGID value, generate a jpeg of the map linked to the SGID (Cadastre ID) and return the output jpeg path as an url that the SSRS can use to access the jpeg to insert it into the report template. We currently have the following CMV viewer (V&V Mapper) that we are using. Our SQL Dev has written a SQL SSRS report that is triggered when the following link (Tablemap) below is selected. TableMap: MoreInfo SSRS URL: "http://197.85.5.236:8080/ReportServer/Pages/ReportViewer.aspx?%2fVnV_BO%2fLanduseSummary&SGID=929102&rs:Format=PDF" I've attached my python script below that as an input argument accepts the SSRS Url and extracts the SGID value using Python Urlparse module (i.e. I'm still using Python 2.7.8 and ArcGIS 10.3.1). '''
Created on 12 Sep 2016
Generate a JPEG
for a Land Parcel
indicating the irrigation
status based on SGID
@author: PeterW
'''
# import site-packages and modules
import urlparse
import math
import arcpy
# set environment settings
arcpy.env.overwriteOutput = True
# set arguments
# example of incomming url from ssrs request:
# http://197.85.5.236:8080/ReportServer/Pages/ReportViewer.aspx?%2fVnV_BO%2fLanduseSummary&SGID=930016&rs:Format=PDF
input_sgid = arcpy.GetParameterAsText(0)
# fixed input mcd and output jpeg folder
input_mxd = r"D:\Python2\VandV\mxd\VandV_Letter_Maps_160928.mxd"
output_folder = r"Z:\Peter.Wilson\test"
# function to extract sgid from sql ssrs url
def extract_sgid(input_sgid):
sgid = urlparse.parse_qsl(urlparse.urlparse(input_sgid).query)[0][1]
return sgid
sgid = extract_sgid(input_sgid)
# function to export map document to jpeg based on sgid
def vandv_ddp_jpegs(input_mxd, sgid, output_folder):
""" export map document to jpeg based on sgid """
mxd = arcpy.mapping.MapDocument(input_mxd)
df = arcpy.mapping.ListDataFrames(mxd)[0]
lyrs = arcpy.mapping.ListLayers(mxd, "", df)
elm_title = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "sgkey")[0]
try:
sqlquery = "{0} = {1}".format("SGID", sgid)
arcpy.MakeFeatureLayer_management(lyrs[0], "Cadastre_lyr", sqlquery)
with arcpy.da.SearchCursor("Cadastre_lyr", ["SGID", "ID", "SHAPE@"]) as scur1: # @UndefinedVariable
for row in scur1:
elm_title.text = row[1]
SGID = row[0]
def_query1 = "{0} = {1}".format("SGID", SGID)
lyrs[0].definitionQuery = def_query1
lyrs[1].definitionQuery = def_query1
df.extent = row[2].extent
df.scale = int(math.ceil(df.scale/5000)*5000)
arcpy.RefreshActiveView()
output_jpeg = "{0}\\{1}.jpg".format(output_folder, SGID)
arcpy.AddMessage("Exporting SGID {0} jpeg".format(SGID))
arcpy.mapping.ExportToJPEG(mxd, output_jpeg, resolution=150)
lyrs[0].definitionQuery = ""
lyrs[1].definitionQuery = ""
except arcpy.ExecuteError:
print(arcpy.GetMessages(2))
return output_jpeg
output_jpeg = vandv_ddp_jpegs(input_mxd, sgid, output_folder) Any suggestions to achieve the following will be appreciated as I've never done the following before. Will the following accept the incoming url from the SSRS request and return the url path to the output jpeg.
... View more
11-03-2016
12:32 PM
|
0
|
0
|
656
|
|
POST
|
HI Tim Thanks for the following, I'll go through the following and let you know if I come right.
... View more
10-19-2016
09:24 PM
|
0
|
0
|
996
|
|
POST
|
I need some advice and direction from the ESRI community. We have made use of the CMV Viewer for a project that we are involved in: Each point refers to the landowners letter and map indicating the irrigated and non irrigated fields on a land parcel (farm portion) The output map is currently generated from a python script, accessing the data directly from the SDE SQL Enterprise Geodatabase based on an mxd that I setup and saved under the server. '''
Created on 12 Sep 2016
Generated a JPEG
for each Land Parcel
indicating the irrigation
status
@author: PeterW
'''
# import site-packages and modules
import math
import arcpy
# set environment settings
arcpy.env.overwriteOutput = True
# set arguments
input_mxd = r"D:\Python2\VandV\mxd\VandV_Letter_Maps_160928.mxd"
output_folder = r"Z:\Peter.Wilson\VandV_Maps"
# function to generate jpeg for each cadastre indicating the irrigation status
def vandv_ddp_jpegs(input_mxd, output_folder):
mxd = arcpy.mapping.MapDocument(input_mxd)
df = arcpy.mapping.ListDataFrames(mxd)[0]
# cadastre and landuse layers
lyrs = arcpy.mapping.ListLayers(mxd, "", df)
elm_title = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "sgkey")[0]
sgid_set = set()
with arcpy.da.SearchCursor(lyrs[1], ["SGID"]) as scur1: # @UndefinedVariable
for row in scur1:
# filter out landuse feature classes that don't have SGIDs
if row[0]!= None:
sgid_set.add(row[0])
sgids = list(sgid_set)
sqlquery = 'SGID IN (' + ','.join(map(str, sgids)) + ')'
arcpy.MakeFeatureLayer_management(lyrs[0], "Cadastre_lyr", sqlquery)
with arcpy.da.SearchCursor("Cadastre_lyr", ["SGID", "ID", "SHAPE@"]) as scur1: # @UndefinedVariable
for row in scur1:
elm_title.text = row[1]
SGID = row[0]
def_query1 = "{0} = {1}".format("SGID", SGID)
lyrs[0].definitionQuery = def_query1
lyrs[1].definitionQuery = def_query1
df.extent = row[2].extent
df.scale = int(math.ceil(df.scale/5000)*5000)
arcpy.RefreshActiveView()
output_jpeg = "{0}\\{1}.jpg".format(output_folder, SGID)
arcpy.AddMessage("Exporting SGID {0} jpeg".format(SGID))
arcpy.mapping.ExportToJPEG(mxd, output_jpeg, resolution=150)
lyrs[0].definitionQuery = ""
lyrs[1].definitionQuery = ""
vandv_ddp_jpegs(input_mxd, output_folder)
The output jpeg looks like the following: What I need to do is convert my python script that it generates the output jpeg (map) using the rest services within the viewer and not accessing the data from the SDE SQL Geodatabase. The Geoprocessing service needs to use as input argument the land parcel ID and the output jpeg needs to be return as an HTML Url that can be consumed by the hyperlink "More Info" that triggers an SSRS (SQL Server Reporting Services) that generates the letter and needs to embed the jpeg thats returned as a Url. The print Geoprocessing Service almost does what I wan't , but I still need to handle the map template, and does the jpeg need to be saved to hard disk or could it be saved into memory and returned as an Url that the SSRS can use to embed into the letter. I don't have any experience in JavaScript, so what do I need to learn to achieve the following. Any suggestions and sample Geoprocessing Services that achieve an similar result to guide me will be greatly be appreciated.
... View more
10-19-2016
01:04 PM
|
0
|
0
|
1188
|
|
POST
|
I need some advice and direction from the ESRI community. We have made use of the CMV Viewer for a project that we are involved in: Each point refers to the landowners letter and map indicating the irrigated and non irrigated fields on a land parcel (farm portion) The output map is currently generated from a python script, accessing the data directly from the SDE SQL Enterprise Geodatabase based on an mxd that I setup and saved under the server. '''
Created on 12 Sep 2016
Generated a JPEG
for each Land Parcel
indicating the irrigation
status
@author: PeterW
'''
# import site-packages and modules
import math
import arcpy
# set environment settings
arcpy.env.overwriteOutput = True
# set arguments
input_mxd = r"D:\Python2\VandV\mxd\VandV_Letter_Maps_160928.mxd"
output_folder = r"Z:\Peter.Wilson\VandV_Maps"
# function to generate jpeg for each cadastre indicating the irrigation status
def vandv_ddp_jpegs(input_mxd, output_folder):
mxd = arcpy.mapping.MapDocument(input_mxd)
df = arcpy.mapping.ListDataFrames(mxd)[0]
# cadastre and landuse layers
lyrs = arcpy.mapping.ListLayers(mxd, "", df)
elm_title = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "sgkey")[0]
sgid_set = set()
with arcpy.da.SearchCursor(lyrs[1], ["SGID"]) as scur1: # @UndefinedVariable
for row in scur1:
# filter out landuse feature classes that don't have SGIDs
if row[0]!= None:
sgid_set.add(row[0])
sgids = list(sgid_set)
sqlquery = 'SGID IN (' + ','.join(map(str, sgids)) + ')'
arcpy.MakeFeatureLayer_management(lyrs[0], "Cadastre_lyr", sqlquery)
with arcpy.da.SearchCursor("Cadastre_lyr", ["SGID", "ID", "SHAPE@"]) as scur1: # @UndefinedVariable
for row in scur1:
elm_title.text = row[1]
SGID = row[0]
def_query1 = "{0} = {1}".format("SGID", SGID)
lyrs[0].definitionQuery = def_query1
lyrs[1].definitionQuery = def_query1
df.extent = row[2].extent
df.scale = int(math.ceil(df.scale/5000)*5000)
arcpy.RefreshActiveView()
output_jpeg = "{0}\\{1}.jpg".format(output_folder, SGID)
arcpy.AddMessage("Exporting SGID {0} jpeg".format(SGID))
arcpy.mapping.ExportToJPEG(mxd, output_jpeg, resolution=150)
lyrs[0].definitionQuery = ""
lyrs[1].definitionQuery = ""
vandv_ddp_jpegs(input_mxd, output_folder)
The output jpeg looks like the following: What I need to do is convert my python script that it generates the output jpeg (map) using the rest services within the viewer and not accessing the data from the SDE SQL Geodatabase. The Geoprocessing service needs to use as input argument the land parcel ID and the output jpeg needs to be return as an HTML Url that can be consumed by the hyperlink "More Info" that triggers an SSRS (SQL Server Reporting Services) that generates the letter and needs to embed the jpeg thats returned as a Url. The print Geoprocessing Service almost does what I wan't , but I still need to handle the map template, and does the jpeg need to be saved to hard disk or could it be saved into memory and returned as an Url that the SSRS can use to embed into the letter. I don't have any experience in JavaScript, so what do I need to learn to achieve the following. Any suggestions and sample Geoprocessing Services that achieve an similar result to guide me will be greatly be appreciated.
... View more
10-19-2016
01:01 PM
|
0
|
3
|
1809
|
|
POST
|
Hi Dan I added them afterwards and rebuilt the Terrain Dataset. I'm not sure if the polylines are mean't to be closed or open on either end of the river\canal.
... View more
09-21-2016
05:35 AM
|
0
|
0
|
840
|
|
POST
|
I'm trying to incorporate breaklines along canals and unlined rivers so that the elevation between the breaklines is filled based on the breaklines. I've tried to follow the concept that ESRI describes within the following help article: Incorporate breaklines with LiDAR. The article doesn't explain in detail the requirements of the feature class that will be used within the LiDAR to achieve the following. The approach that I've used so far is to generate polylines that represent the location of the breaklines that I wish to use within my Terrain. I then used 3D Analyst tool: Interpolate Shape. to extract the elevation levels from the terrain. I then added the following to my Terrain as SFType : Hardline. My current results don't represent the results that I'm expecting that is explained within the Incorporate breaklines with LiDAR documentation. Current Results with breaklines, canals are not filled Incorporate breaklines with LiDAR documentation: Filled River Section. Any help in what step that I'm missing the achieve the following will be appreciated.
... View more
09-21-2016
12:04 AM
|
0
|
2
|
1819
|
|
POST
|
I'm trying to incorporate breaklines along canals and unlined rivers so that the elevation between the breaklines is filled based on the breaklines. I've tried to follow the concept that ESRI describes within the following help article: Incorporate breaklines with LiDAR. The article doesn't explain in detail the requirements of the feature class that will be used within the LiDAR to achieve the following. The approach that I've used so far is to generate polylines that represent the location of the breaklines that I wish to use within my Terrain. I then used 3D Analyst tool: Interpolate Shape. to extract the elevation levels from the terrain. I then added the following to my Terrain as SFType : Hardline. My current results don't represent the results that I'm expecting that is explained within the Incorporate breaklines with LiDAR documentation. Current Results with breaklines, canals are not filled Incorporate breaklines with LiDAR documentation: Filled River Section. Any help in what step that I'm missing the achieve the following will be appreciated.
... View more
09-20-2016
08:28 AM
|
0
|
0
|
816
|
|
POST
|
Hi Dan Thanks for the following Is this still true if you are using 64 bit background processing and running the python script as a standalone process?
... View more
09-01-2016
05:14 AM
|
0
|
2
|
1548
|
|
POST
|
I'm looking for a reasonable workflow to generate DEM's from contours for multiple study areas without having to clip my contours into tiles in order to generate a DEM. I'm looking for suggestions from the community in being able to process large datasets (contours) by processing the study area into usable tiled areas such as the Tiled processing that ESRI has developed for certain geoprocessing tools: I'd like to generate a tiled index on the fly based on the extent of my study area and output cellsize, in order to process my study area in tiles and then stitch the tiles together to generate a single DEM. Topo to Raster is written in Fortran and doesn't take advantage of multiple processors or cores. Its limited in the amount of memory that is allocated to the single geoprocessing tool, so I'm trying to develop a Python workflow of splitting the study area into small enough areas that can be run simultanously and then stitched back together afterwards. My current study area is made up of nine local municipalities and from my calculations based on a 10m cellsize each local municipality will have the following amount of cells for each DEM: Baviaans 226 791 600 Blue Crane Route 209 397 384 Camdeboo 250 726 124 Ikwezi 86 625 374 Kouga 50 539 474 KouKamma 73 776 259 Makana 40 357 026 Ndlambe 40 357 026 Nelson Mandela Bay 34 654 290 Sunday's River Valley 114 374 190 Nine Local Municipalities
... View more
09-01-2016
02:41 AM
|
0
|
6
|
2933
|
|
POST
|
Hi Rebecca Thanks for the following, it truly helpful
... View more
08-30-2016
12:34 AM
|
0
|
0
|
1446
|
|
POST
|
I've been creating Python Scripts and Program's for years, but have never really needed to share my script with anyone else. I generally run them directly from my IDE manually or schedule them to run from my server. I'm currently helping out a colleague and have written a Python Script for them. I added the python script to a a ArcToolbox and found my first stumbling block. The formatting of the Description is not maintained. As can be seen from below the paragraphs are clearly visible within the properties of the script: Python Script Tool: Properties Python Script Tool: Paragraphs are dropped. Where can I find documentation on controlling how the description and help documentation is displayed and how to customize it? The second problem that I picked up is that the Data Type integer (Int\Short) is not available from the drop down list of data_types: Data Type: Short Missing from drop down list ??? I've changed the type to "Long" for now which seems unnecessary and converted it to an integer within my Python Script. Whats the reasoning that Integer Data Type is not available within the available data types?
... View more
08-29-2016
02:32 AM
|
0
|
7
|
2247
|
| Title | Kudos | Posted |
|---|---|---|
| 3 | 01-16-2012 02:34 AM | |
| 1 | 05-07-2016 03:04 AM | |
| 1 | 04-10-2016 01:09 AM | |
| 1 | 03-13-2017 12:27 PM | |
| 1 | 02-17-2016 02:34 PM |
| Online Status |
Offline
|
| Date Last Visited |
03-04-2021
12:50 PM
|