POST
|
line 19. You are changing Connections, not featureclass paths. (I do not know why a shapefile exists in your system!!) I could not find one to test out your script! line 19. The updateConnectionProperties is a search and replace function, so you need to have a string replace option, not a full path option line 9 . If you are comparing paths it is safer to normalize the paths for string comparisons using old = os.path.normpath(old_path). Maybe updateFolderConnections would work better for shapefiles Also you are changing the wrong object source. The project has a separate connections. You should be changing the Layer connection properties.
... View more
Friday
|
0
|
0
|
45
|
IDEA
|
And now we have BigInteger (64bit) which have appeared since 3.2 that are not interchangeable with Long Integer or Short Integer in many tools. eg RelationshipClasses do not allow them as a valid type for a key.
... View more
4 weeks ago
|
0
|
0
|
62
|
POST
|
I agree with @JohannesBierer that you must not divide up the river, leave it as a line. The Near tool find the perpendicular distance and the xy point at the intersection of the river as attributes which you can then use.
... View more
4 weeks ago
|
1
|
0
|
80
|
POST
|
The limit for a shapefile field is 10 characters. Are you really still using shapefiles? Not really very sympathetic if you are! Maybe you have a path problem so you are pointing at a folder and not a geodatabase. Some example code might help others explain the probably "obvious" error.
... View more
4 weeks ago
|
0
|
0
|
67
|
POST
|
I have found other problems with 64 bit Integers now called BigInteger. Integer fields defined in geopackages and spatialite are now cast by default to BigInteger instead of Integer. RelationshipClasses cannot use them which was a surprise because I suddenly had BigIntegers for every primary and foreign key in my database. I have had to go back and explicitly cast to Integer (32 bit) using FieldMapping on every copy operation so I am not surprised that Pandas needs editing. Just about to do some datetime manipulation, thanks for the heads-up.
... View more
4 weeks ago
|
0
|
0
|
88
|
IDEA
|
When importing data from geopackage or sqlite any field defined as Integer in the DDL gets cast to BigInteger instead of (Long) Integer. This is a new incompatible behaviour since BigIntegers were included (ArcPro 3.2?). There are several tools that do not work with BigIntegers such as RelationshipClasses. It would be helpful if there was a switch to turn off this unwelcome enhancement. The only way to fix the problem is to define a FieldMapping on every copy operation and there are many of these that do not have FieldMapping as a parameter. If the field is readonly such as OBJECTID then it cannot be changed at all. I see another user has used FME to fix this. This is like a reverse single precision / double precision incompatibility! Maybe a switch somewhere in the settings or the environment settings to retrofit a fix?
... View more
4 weeks ago
|
2
|
3
|
190
|
POST
|
ArcGISPro is apparently backward compatible with ArcMap but I have found a serious limitation in the TableToRelationshipClass_management tool when finally upgrading my scripts. ArcGISPro will only accept GlobalIDs or String fields as keys and only String fields in the relation table. What has happened to Integer fields? These were apparently Best Practice in database design for Primary and Foreign keys. Edit: it appears that Big Integers are not supported, Short and Long are allowed, but if a sqlite table is being translated INTEGER type is by default typecast to BigInteger. But these are not supported in Relationship Classes. I have a clone of a large survey database ( 50 tables, 70 GB) that uses Integer for nearly every table which I use in the relationship class definition. There is also a sequence field used to order related records that is integer (of course). Choices: a. I could adopt GlobalID - GUID relationships. This is a lot of additional work, not in the source tables. The GlobalID is readonly and not under my control. It can be changed arbitrarily by Esri tools if they consider the feature is "new" thus breaking the link to the foreign key. b. I could copy the integer keys to strings just for the relates. This is also a lot of work (60 min processing per relate x 5 relations, indexing, rebuild the relate. At least I am still in control and the keys are static. I do not do any editing except for bulk validation, subsets, copies. c. Force a cast of all integers in the entire database to Long instead of Big Integer when translating. Using string values for integers does work but takes over an hour to build the relation class. using GlobalID-GUID pairs is faster at 7 minutes. The proper solution is to return to basics and somehow force the cast to Long everywhere. To do that I found I had to remove deprecated tools TableToTable and MakeFeatureLayer/CopyFeatures with tools from the Conversion toolbox: ExportTable and ExportFeatures which have a parameter to include a FieldMappings/FieldMap/Field expression that allowed me to override the default and change the field_type before copying to a filegeodatabase. I also had to replace the simpler FieldInfo parameter which does not allow type mappings. If you are only doing a couple the interactive tool lets you define the fieldmap, but in Python it is a nightmare of obscure FieldMapping objects. If only there was an environment variable to switch the default Integer type to Long instead of BigInteger.
... View more
a month ago
|
0
|
0
|
195
|
POST
|
Yes you can. Try it. Relates are hard to use. You can get a tree when querying with a popup. You can also select from a table and find related selections with the hamburger at the end of the table view. It requires manual triggering every time [Not like ArcView 3 and Avenue Dialog Designer where the selected records are highlighted, you can raise the selection to the top, not just filter and generally have a much better experience.]
... View more
a month ago
|
0
|
0
|
29
|
POST
|
Have a look at the validation tools in the forms. You can program up a really complex interface with a bit of python programming, have error messages and check it is valid before starting the run. You can even program the whole form up in python so you don't use the wizard at all, I haven't gone to that step myself. Here is an example that analyses our census data. http://www.ollivier.co.nz/support/census2018/index.htm
... View more
a month ago
|
0
|
0
|
63
|
POST
|
Well I think that a list comprehension wrapped around a da.SearchCursor is a very efficient and fast way to extract the features into a more open format. But why do you think that Pandas (a non spatial module) would handle spatial data? I am impressed that it worked at all! Have you considered GeoPandas? That does handle shape columns and provides you with spatial functions. Or maybe use the arcgis module? That has spatial extensions for pandas where geojson data returned by the Python Rest API is handled smoothly. There is another way to extract the features - use Numpy. There is a function in the da module FeatureClassToNumPyArray that translates directly from a featureclass to a numpy array. Maybe you can convert from the numpy array to a dataframe? Finally there are Geometry Objects. These are in-memory arrays of the geometry from a featureclass that have a complete set of spatial operators built in. Every spatial tool in the toolbox has an equivalent function for pairs of geometry objects that do not need an advanced licence. You can write a complete ArcGIS clone using a Basic licence. I do this for selected operations if needed to be restricted to a Basic licence or if I find a faster way by short-cutting the search.
... View more
a month ago
|
0
|
0
|
56
|
POST
|
There is no need to create a new class. Just a function would do. Shapefiles are obsolete with lots of limitations, use a featureclass in a filegeodatabase. Then you can have null geometry for example. There are much easier ways of loading data that this painful way that is also very old. Here are 5 records of the in the PointFile ====================== id, shapeId, x, y, z 1,1,2197490.3821680555,1.5003079009938888E7,1573.2872741540364 2,2,2197478.7284111492,1.5003076194199622E7,1570.29 3,3,2197459.2878189506,1.500307149703293E7,1570.29 4,4,2197446.2932236306,1.5003068357325058E7,1573.6321294959107 5,5,2197490.3821680555,1.5003079009938888E7,1573.2872741540364 Here is the python program =================== import arcpy import os class TextToShapefileConverter: def __init__(self, input_directory, output_directory, spatial_reference_id=26914😞 self.input_directory = input_directory self.output_directory = output_directory self.spatial_reference_id = spatial_reference_id self.spatial_reference = arcpy.SpatialReference(self.spatial_reference_id) def convert(self, point_file_name): input_text_file = os.path.join(self.input_directory, point_file_name) output_shapefile_name = os.path.splitext(point_file_name)[0] + '.shp' output_shapefile = os.path.join(self.output_directory, output_shapefile_name) print "generating", output_shapefile_name if "PolygonPointFile" in point_file_name: self._create_polyline_shapefile(output_shapefile, input_text_file) # self._create_polygon_shapefile(output_shapefile, input_text_file) def _create_polyline_shapefile(self, output_shapefile, input_text_file): arcpy.env.overwriteOutput = True arcpy.CreateFeatureclass_management( os.path.dirname(output_shapefile), os.path.basename(output_shapefile), "POLYLINE", has_z="ENABLED", has_m="DISABLED", spatial_reference=self.spatial_reference) arcpy.AddField_management(output_shapefile, "PairID", "LONG") cursor = arcpy.da.InsertCursor(output_shapefile, ['SHAPE@', 'PairID']) points = [] pair_id = 0 with open(input_text_file, 'r') as file: next(file) # Skip header for line in file: if line.strip(): _, _, x, y, z = line.split(',') point = arcpy.Point(float(x), float(y), float(z)) points.append(point) # Check if a pair of points has been added if len(points) == 5: print points polyline = arcpy.Polyline(arcpy.Array(points), self.spatial_reference, True) cursor.insertRow([polyline, pair_id]) points = [] # Reset for next pair pair_id += 1 del cursor def _create_polygon_shapefile(self, output_shapefile, input_text_file): arcpy.env.overwriteOutput = True arcpy.CreateFeatureclass_management( os.path.dirname(output_shapefile), os.path.basename(output_shapefile), "POLYGON", has_z="ENABLED", has_m="DISABLED", spatial_reference=self.spatial_reference) arcpy.AddField_management(output_shapefile, "GroupID", "LONG") cursor = arcpy.da.InsertCursor(output_shapefile, ['SHAPE@', 'GroupID']) points = [] group_id = 0 with open(input_text_file, 'r') as file: next(file) # Skip header for line in file: if line.strip(): id, _, x, y, z = line.split(',') point = arcpy.Point(float(x), float(y), float(z)) points.append(point) if len(points) == 5: if points[0] != points[-1]: points.append(points[0]) # Ensure the polygon is closed polygon = arcpy.Polygon(arcpy.Array(points), self.spatial_reference, True) cursor.insertRow([polygon, group_id]) points = [] # Reset for next group group_id += 1 del cursor if __name__ == "__main__": input_directory = r'C:\Tutorial\GIS\ArcPyTutorial\Data\MyTestFolder' output_directory = r'C:\Tutorial\GIS\ArcPyTutorial\Data\MyTestFolder\outPut' converter = TextToShapefileConverter(input_directory, output_directory) # Process each file for filename in os.listdir(input_directory): if filename.endswith('.txt'😞 converter.convert(filename)
... View more
02-11-2024
03:20 AM
|
0
|
0
|
139
|
POST
|
Yes, well the Pro developers forgot to read the ArcMap manuals.... there is now a synonym to patch up the syntax. I presume that it is a different mechanism under the hood. It never worked reliably for me anyway, so I just use an SSD drive as my scratch.gdb. You can easily run out of memory if you do not release the features, and who does that? Also projections did not work etc.
... View more
02-11-2024
02:58 AM
|
0
|
0
|
104
|
POST
|
Save (in_)memory for simple tasks. It is a lot of people's experience that it does not always work for complex tasks like Dissolve. It did not work for me with geometry objects or reprojections. If you have an SSD then define a partition or just a disk letter and use that for the scratch.gdb and other temporary featureclasses. Since it is effectively equivalent hardware you will get all the benefits of cached read/writes and more reliable operation with the same speed and not run out of memory.
... View more
02-11-2024
02:54 AM
|
0
|
0
|
105
|
POST
|
They look like reserved words in the dropdown data types for parameters to me. Maybe escape them somehow if you have to use them. If you run arcpy.ValidateFieldName() it might prepend underscores if the test finds unacceptable field names. Its a fairly bad bug that these keywords have overflowed into the parameter space. ValidateFieldName(name, workspace=None) ValidateFieldName(name, {workspace}) Takes a string (field name) and a workspace path and returns a valid field name based on name restrictions in the output geodatabase. All invalid characters in the input string will be replaced with an underscore (_). The field name restrictions depend on the specific database used (Structured Query Language [SQL] or Oracle). name(String): The field name to be validated. If the optional workspace is not specified, the field name is validated against the current workspace. workspace{String}: An optional specified workspace to validate the field name against. The workspace can be a file system or a personal, file, or enterprise geodatabase. If the workspace is not specified, the field name is validated using the current workspace environment. If the workspace environment has not been set, the field name is validated based on a folder workspace.
... View more
02-11-2024
02:46 AM
|
0
|
0
|
85
|
POST
|
Actually you cannot use numeric codes for text fields any more at ArcGISPro in domains.They only allow ranges with digits. It does half work in ArcMap but the text is always right justified and the widths go wonky. So even if you want to use digits, for say sorting they have to be character strings. I still hate this because our postal service uses leading zeros. My postcode is "0626" but if Excel get hold of that it morphs into 626 and so on. Sometimes export tools allow you to choose between the code and description but since I am a programmer the codes will do just fine because you Have to use the code in SQL expressions anyway.
... View more
02-11-2024
02:35 AM
|
0
|
0
|
62
|
Title | Kudos | Posted |
---|---|---|
2 | 4 weeks ago | |
1 | 4 weeks ago | |
1 | 03-15-2023 06:41 PM | |
2 | 03-11-2023 03:47 PM | |
1 | 09-04-2022 03:45 AM |
Online Status |
Offline
|
Date Last Visited |
yesterday
|