|
POST
|
Did you try the alternative: Layer.replaceDataSource(workspace_path, workspace_type, dataset_name, {validate}) ArcGIS Help (10.2, 10.2.1, and 10.2.2)
... View more
01-29-2015
06:12 PM
|
1
|
0
|
2832
|
|
POST
|
You can create a new toolbox in the Catalog window inside ArcMap of in ArcCatalog. I used the Catalog Window in ArcMap. Go to the folder where you want to create the toolbox, right click and select the option "New > Toolbox" from the context sensitive menu. Rename the Toolbox (by default named "Toolbox.tbx") into a name that suites you (leave the extension .tbx unchanged). Next you can add the script: right click on the toolbox select the option "Add> Script" from the context sensitive menu. Next follow the instructions here about adding a script tool: http://resources.arcgis.com/en/help/main/10.2/index.html#/Adding_a_script_tool/00150000001r000000/ and this topic that talks about how to structure the folders of your tool: http://resources.arcgis.com/en/help/main/10.2/index.html#//01m10000000s000000#GUID-5118AC85-57E4-4027-AC24-FB6E99FADEFF and this topic about setting the parameters for the tool. ArcGIS Help (10.2, 10.2.1, and 10.2.2) For coding I use PyScripter which you can download for free here: Downloads - pyscripter - An open-source Python Integrated Development Environment (IDE) - Google Project Hosting (use the 32 bits version, since ArcGIS for Desktop 10.x is 32 bits)
... View more
01-29-2015
06:00 PM
|
2
|
8
|
2863
|
|
POST
|
You can use this code: import arcpy
fc_in = r"C:\Forum\test.gdb\Polyline_chord"
fc_out = r"C:\Forum\test.gdb\Polyline_straight"
sr = arcpy.Describe(fc_in).spatialReference
lines = []
with arcpy.da.SearchCursor(fc_in, ("SHAPE@")) as curs:
for row in curs:
polyline_in = row[0]
polyline_out = arcpy.Polyline(arcpy.Array([polyline_in.firstPoint, polyline_in.lastPoint]), sr)
lines.append(polyline_out)
arcpy.CopyFeatures_management(lines, fc_out) Kind regards, Xander
... View more
01-29-2015
01:24 PM
|
2
|
0
|
1749
|
|
POST
|
I think it would be something like this (did not test it though): import arcpy
import os
fc_in = r"C:\Forum\test.gdb\Polygon"
fc_out = r"C:\Forum\test.gdb\Points"
interval = 50
fld_in = "TheNameOfTheFieldYourWantToIncludeInYourOutput"
# determine the input spatial reference
sr = arcpy.Describe(fc_in).spatialReference
# create the empty output featureclass
fc_ws, fc_name = os.path.split(fc_out)
arcpy.CreateFeatureclass_management(fc_ws, fc_name, "POINT", spatial_reference=sr)
# add the field to the output
fld = arcpy.ListFields(fc_in, wild_card=fld_in)[0]
arcpy.AddField_management(fc_out, fld_in, fld.type, fld.precision, fld.scale, fld.length)
# start output cursor
with arcpy.da.InsertCursor(fc_out, ("SHAPE@", fld_in)) as curs_out:
with arcpy.da.SearchCursor(fc_in, ("SHAPE@", fld_in)) as curs_in:
for row_in in curs_in:
polygon = row_in[0]
outline = polygon.boundary()
value = row_in[1]
d = 0
while d < outline.length:
pnt = outline.positionAlongLine(d, False)
curs_out.insertRow((pnt, value, ))
d += interval
... View more
01-29-2015
12:28 PM
|
0
|
0
|
5130
|
|
POST
|
I would probably create the output table first, add the fields and use an insert cursor to fill the table: import os
fgdb = r"C:\dev_folder\orginalDev.gdb"
tbl_name = "jsoncsv2"
tbl = os.path.join(fgdb, tbl_name)
fld_lat = "Latitude"
fld_lon = "Longitude"
arcpy.CreateTable_management(fgdb, tbl_name)
arcpy.AddField_management(tbl, fld_lon, "DOUBLE")
arcpy.AddField_management(tbl, fld_lat, "DOUBLE")
flds = (fld_lon, fld_lat)
with arcpy.da.InsertCursor(tbl, flds) as curs:
for items in parsed_json['items']:
row = (float(items['longitude']), float(items['latitude']), )
curs.insertRow(row)
... View more
01-29-2015
10:47 AM
|
3
|
0
|
1884
|
|
POST
|
I probably would not use the Merge tool for this. Especially if you are not interesting in the attributes (only geometry). You could probably do something like this. Please not that I did not run the code, so be careful... ... but if it works it will: create an empty output featureclass (which should not be written to the folder that is being searched) searches for featureclasses of type polygon in the folder and all subfolders use a search cursor to obtain the geometry and insert it in the output featureclass import arcpy
import os
arcpy.env.overwriteOutput = True
# settings
basefolder = r"C:\Forum"
fc_out = r"C:\Data\myFGDB.gdb\myResultingFeatureclass"
sr = arcpy.SpatialReference(102100) # specify the correct WKID!
# create the empty output fc (outside the basefolder!)
fc_ws, fc_name = os.path.split(fc_out)
arcpy.CreateFeatureclass_management(fc_ws, fc_name, "POLYGON", spatial_reference=sr)
cnt = 0
# start a da insert cursor
with arcpy.da.InsertCursor(fc_out, ("SHAPE@")) as curs_out:
# create a list of all polygon featureclasses in (sub)folders of the basefolder
walk = arcpy.da.Walk(basefolder, datatype="FeatureClass", type="Polygon")
# loop through featureclasses
for dirpath, dirnames, filenames in walk:
for filename in filenames:
# construct the absolute name to input featureclass
fc_in = os.path.join(dirpath, filename)
# for shapefiles (but also coverages)
desc = arcpy.Describe(dirpath)
if hasattr(desc, "workspaceType"):
if arcpy.Describe(dirpath).workspaceType == "FileSystem":
# start search cursor and insert features into output featureclass
print "Processing featureclass: '{0}'".format(filename)
with arcpy.da.SearchCursor(fc_in, ("SHAPE@")) as curs_in:
for row in curs_in:
cnt += 1
if cnt % 1000 == 0:
print " - Inserting output feature: {0}".format(cnt)
curs_out.insertRow((row[0], ))
del curs_out, curs_in, row A simple enhancement could be to add a field to the output featureclass (text) and write the source shapefile name to the field. There is no check to see if the coordinate system coincides with the output featureclass. Also other polygon featureclasses like coverages, if present, will be included in the result.
... View more
01-28-2015
07:32 PM
|
1
|
5
|
4519
|
|
POST
|
Can you explain what exactly it is you mean by "chord"? If you have a picture to explain what you are after that would be helpful too.
... View more
01-28-2015
02:25 PM
|
2
|
2
|
1749
|
|
POST
|
If you use the Reclassify tool (Spatial Analyst Toolbox), you can assign an output value to each range of slope value. You can read more about this here: ArcGIS Help (10.2, 10.2.1, and 10.2.2) Create the 11 classes, reclassify and assign 10 to the flattest area and 0 to highest slope (and 1-9 to the intermediate classes).
... View more
01-28-2015
02:22 PM
|
0
|
0
|
2146
|
|
POST
|
If you want some python examples of how to extract features from a REST end point using python, you can find some in this thread: Re: Extract Features From MapServer/ Rest/ Soap/ etc? Jake Skinner created a toolbox to do this. There are also references to some python code I write to do this: the simple way: https://community.esri.com/thread/118781#445348 or using a little more advanced: https://community.esri.com/thread/118781#445572 You can find an example of updating a feature service through Python and REST here: Re: UpdateFeature REST API Python Script Unexpected Error
... View more
01-28-2015
02:16 PM
|
2
|
0
|
1649
|
|
POST
|
pan lu, could you mark the thread as answered? In the lower left corner of Melita's post, there should be a button "Correct Answer".
... View more
01-28-2015
12:59 PM
|
0
|
1
|
3111
|
|
POST
|
If you can include all the data you mentioned (for a representative part), I can have a look what the possibilities are. No promises though...
... View more
01-28-2015
12:42 PM
|
0
|
0
|
4492
|
|
POST
|
Hi, Is it possible to start a new thread and include some more details about what you're after? Maybe include some sample data or an image that explains the situation? Kind regards, Xander
... View more
01-28-2015
11:17 AM
|
0
|
1
|
6970
|
|
POST
|
If you're willing to share a small part of your data (or if you can generate some dummy data following the same format) I could have a look if with some python coding the stratigraphic layers and excavation units can be extracted.
... View more
01-28-2015
10:23 AM
|
0
|
3
|
4492
|
|
POST
|
I think you an issue with the decimal sign of the coordinates. If your x-coord (longitude) is expressed in meters, it would be like 25-26 times the circumference of the world. That doesn't make sense.
... View more
01-28-2015
10:03 AM
|
0
|
2
|
3107
|
|
POST
|
According to the Help you should be able to use arcpy.da.Walk to loop through the mxd files in a folder (and subfolders): import arcpy
import os
workspace = r"D:\Xander\GeoNet"
walk = arcpy.da.Walk(workspace, datatype="Map")
for dirpath, dirnames, filenames in walk:
for filename in filenames:
mxdfile = os.path.join(dirpath, filename) ... but when I tried it didn't give me any result. However, you can use: import arcpy
import os
import fnmatch
directory = r"D:\Xander\GeoNet"
pattern = "*.mxd"
for root, dirs, files in os.walk(directory):
for filename in fnmatch.filter(files, pattern):
mxdfile = os.path.join(root, filename)
print "mxd file: {0}".format(mxdfile)
mxd = arcpy.mapping.MapDocument(mxdfile)
dfs = arcpy.mapping.ListDataFrames(mxd)
for df in dfs:
print " - data frame: {0}".format(df.name)
for lyr in arcpy.mapping.ListLayers(mxd, data_frame=df):
print " - layer name: {0}".format(lyr.name) ... to loop through the mxd's, the data frames and layers within the dataframes. To update any datasource I recommend you to read this page of the Help: ArcGIS Help (10.2, 10.2.1, and 10.2.2)
... View more
01-28-2015
09:50 AM
|
1
|
0
|
1922
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 01-09-2020 09:26 AM | |
| 6 | 12-20-2019 08:41 AM | |
| 1 | 01-21-2020 07:21 AM | |
| 2 | 01-30-2020 12:46 PM | |
| 1 | 05-30-2019 08:24 AM |
| Online Status |
Offline
|
| Date Last Visited |
a month ago
|