|
POST
|
There are two obvious tools to create a set of index sheets based on the centroids. Do you have a sheet size in mind? Thanks for the sample that makes it much easier to experiment. The first thing I did was to project the data to a filegeodatabase so that I have feet units. My first attempt was to just create Thiessen polygons around the points. This works well for even spacing. There are a few long bits around the edges. You could trim them up and straighten the fuzzy bits by snapping to the larger index. I then tried a Graphic Buffer with a size of 290 metres. This also gave a good start, a bit of integration would snap the overlaps to a tidy grid.
... View more
12-03-2024
03:46 AM
|
0
|
0
|
767
|
|
IDEA
|
Even if the policy is correctly set for casting the ambiguous Integer type I still need a solution that works for me. I can see that computing has evolved from 16 to 32 to 64 bit integers and some are defined as signed and unsigned. I have seen LONG, MEDINT, INTEGER and SHORT as well as the new BigInteger to try to extend the meaning of 'LONG' which in 32 bit days meant only 32 bits. To keep backward compatibility the temptation is to reuse 'Long' for 64 bit when using a 64 bit compiler. I was interested to see that MEDINT was interpreted as Long and INTEGER as BigInteger going from a gpkg to a filegeodatabase. So redefining the gpkg field type might be a good workaround that avoids having to explicitly cast the fieldtype using a fieldmappings parameter with ExportFeatures_conversion() replacing CopyFeatures(). [note that sqlite does not care what you call it in the DDL, they are always 64 bit integers internally] The small print in the help also explains why the option setting in Options in ArcGISPro does not work for me. Because if running a script outside ArcGISPro in the command line you have to set the options in the arcpy environment. arcpy.env. But Double is useless for me. I want to use the field as an indexed key so it has to be some sort of integer. Insert below: useCompatibleFieldTypes (Read and Write) Specifies whether field types that are compatible with ArcGIS Pro 3.1 will be used. This setting relates to the use of the Date Only, Time Only, Timestamp Offset, and Big Integer field types in CSV tables and unregistered database tables with tools that create layers or table views. When set to True, a layer or table view created from these sources will use field types compatible with ArcGIS Pro 3.1. Date Only, Time Only, and Timestamp Offset fields will be displayed as Date fields, and Big Integer fields will be displayed as Double fields. When set to False, all original data source field types will be used. Note: This property is applicable when used from stand-alone Python or for a geoprocessing service. When used in ArcGIS Pro, this property will always match the Use field types that are compatible with ArcGIS Pro 3.1 and earlier releases when adding query layers and text files option. A better option I have implemented is to replace CopyFeatures_management() with my own function CopyFeaturesLong() that looks for any BigInteger arcpy interpretations and keeps them as a compatible Integer, not a Double. Here it is if you want to use it. There will need to be a similar function to replace CopyRows(). def CopyFeaturesLong(input_fc, output_fc):
"""CopyFeatures replacement
to ensure every BigInteger is mapped to Long
with a fieldmappings parameter using arcpy.conversion.ExportFeatures()
with a bit of help from copilot!
full paths to featureclasses assumed """
# Create FieldMappings and FieldMap objects
field_mappings = arcpy.FieldMappings()
# List of fields to process
# it would be nice if objectid and shape could be excluded easily
fields = arcpy.ListFields(input_fc)
for field in fields:
if field.type not in ('OID', 'Geometry'): # not allowed in fieldmappings
field_map = arcpy.FieldMap() # new for each field
field_map.addInputField(input_fc, field.name)
# Check if the field type is BigInteger and change to Long
field_name = field_map.outputField
if field_name.type == 'BigInteger':
field_name.type = 'Long'
field_map.outputField = field_name
# Add the FieldMap to the FieldMappings object
field_mappings.addFieldMap(field_map)
# Use ExportFeatures to apply the field mappings and create the output feature class
arcpy.conversion.ExportFeatures(input_fc, output_fc, field_mapping=field_mappings)
if debug:
for fld in arcpy.ListFields(output_fc):
print(fld.name,fld.type)
print(f"{output_fc} Feature class successfully exported with updated field types!")
return True
def CopyRowsLong(input_tab, output_tab):
"""CopyRows replacement
to ensure every BigInteger is mapped to Long
with a fieldmappings parameter using arcpy.conversion.ExportTable()
with a bit of help from copilot!
full paths to featureclasses assumed """
# Create FieldMappings and FieldMap objects
field_mappings = arcpy.FieldMappings()
# List of fields to process
# it would be nice if objectid and shape could be excluded easily
fields = arcpy.ListFields(input_tab)
for field in fields:
if field.type not in ('OID', 'Geometry'): # not allowed in fieldmappings
field_map = arcpy.FieldMap() # new for each field
field_map.addInputField(input_tab, field.name)
# Check if the field type is BigInteger and change to Long
field_name = field_map.outputField
if field_name.type == 'BigInteger':
field_name.type = 'Long'
field_map.outputField = field_name
# Add the FieldMap to the FieldMappings object
field_mappings.addFieldMap(field_map)
# Use ExportFeatures to apply the field mappings and create the output feature class
arcpy.conversion.ExportTable(input_tab, output_tab, field_mapping=field_mappings)
if debug:
for fld in arcpy.ListFields(output_tab):
print(fld.name,fld.type)
print(f"{output_tab} Table class successfully exported with updated field types!")
return True
... View more
11-02-2024
03:45 PM
|
0
|
0
|
8189
|
|
POST
|
Correction: you cannot hide fields in Pro, they all have to be visible.
... View more
09-28-2024
08:04 PM
|
0
|
0
|
3478
|
|
POST
|
prefix = '\"%s\"' % sys.prefix
!conda install --yes --prefix {prefix} geopandas
... View more
09-19-2024
04:10 AM
|
2
|
0
|
1746
|
|
POST
|
I am interested in your workflow. I do an identical task. I prototyped it in Pro and then moved it to a Notebook online. I could not use arcpy online, only arcgis so I found Pandas did help. If you get feedback that you don't have edit rights reported then I would take notice. I get this sort of thing, such as arcpy.Exists() not finding a file. Note that Esri has just completely revamped user roles, licencing, permissions. Have a look at the new system. Are you the owner of the FeatureLayers?
... View more
09-18-2024
11:26 PM
|
0
|
0
|
1284
|
|
POST
|
Still a problem for me at Sept 2024. Sort of works if you add a WFS source from the MapViewer, but not if you add it as a FeatureLayer. It ignores the layer dropdown list and just picks the first one.
... View more
09-18-2024
11:09 PM
|
0
|
1
|
1966
|
|
POST
|
The only way I have done this is by using the Python API and Pandas to find the maximum value and then update a field
... View more
09-18-2024
04:56 PM
|
0
|
0
|
1788
|
|
POST
|
"Not all Arcade functions are suitable for every profile. For example, profiles that execute expressions for all features in a layer (e.g. visualization and labeling) don't allow expressions to access data via FeatureSet functions." I don't think you are allowed to use Arcade in a map filter because of the overhead implied. You will have to process the highest value earlier before the data is in a MapView.
... View more
09-17-2024
05:44 PM
|
0
|
0
|
1824
|
|
IDEA
|
It can be done everywhere else! Dashboards can do it. Pro can do it. ArcView 3 could do it. There was a concept plugged by Esri as a 'join by shape field' that was intuitive and spacey. What else is more fundamental in a GIS? There is a manual tool that does an Intersect to a new static Feature Layer that also costs a lot of credits, not good enough.
... View more
09-17-2024
03:39 PM
|
0
|
0
|
630
|
|
POST
|
I appears that the field item is not recognised as numeric. I am also wrestling with WFS feeds being read only and intermittent. My idea is to copy the WFS feed to a real Feature Layer daily that you have full control over the schema and also filters. This is easy from Pro, but not ideal and not automated. So maybe a AGOL Notebook with a Task to refresh each night? I found Arcade is disabled for WFS layers so that is not an option.
... View more
09-17-2024
03:19 PM
|
0
|
0
|
1840
|
|
POST
|
If you put both feature layers into a FeatureLayerCollection then you can turn them both on or off together.
... View more
09-17-2024
03:13 PM
|
0
|
5
|
3963
|
|
POST
|
I cannot get WFS to work correctly in AGOL by adding a feed as a FeatureLayer. It sort of works but ignores the layer selection and simply gets the first layer. If I use a WebMap and add a layer with a source as WFS then the same dialogs appear and the layer selection does work to produce a map layer. Fine, but it is not very useful because I cannot use Arcade on it. It is read-only. I can add a cql_filter with custom parameters. Finally I cannot export it to a FeatureLayer from the WebMap. It is slightly promising because it indicates that it might work if the bug when defining a FeatureLayer source is fixed. I really need to copy the WFS layers into a proper FeatureLayer Collection. You CAN do this easily using Pro! Set up a new WFS server in ArcCatalog, including custom parameters as required, add the layers to the table of contents. Turn off some fields, add more filters, rename layers, load metadata and edit, set up symbology. Change the download limits from 3000 to 100,000. Now just Share to AGOL! Any schema change or new data requires manually replacing the layer, watch out for caches. Now I want to automate this with Python. Particularly in AGOL using a Notebook and a Task. Seems to be possible with the new Pandas SeDF (spatially enabled dataframe) in arcgis package. Not so fast! Loading WFS features into Pandas sdf. This should be easy to do with python requests and geopandas. There are new functions in arcgis to translate from geopandas to sdf and from sdf to a FeatureLayer. You need to import geopandas so that you can read the WFS feed directly into a sdf data frame first. There is a posting noting that you cannot read a WFS feed directly into an Esri sedf. Catch 22 - you cannot import geopandas in a AGOL notebook because it is a Docker instance started up each time. It can work from a Desktop because you can set up a venv that does have geopandas. So how can I install geopandas in AGOL Notebook?
... View more
09-17-2024
03:10 PM
|
1
|
3
|
1796
|
|
POST
|
I cannot get WFS to work correctly in AGOL by adding a feed as a FeatureLayer. It sort of works but ignores the layer selection and simply gets the first layer. If I use a WebMap and add a layer with a source as WFS then the same dialogs appear and the layer selection does work to produce a map layer. Fine, but it is not very useful because I cannot use Arcade on it. It is read-only. I can add a cql_filter with custom parameters. Finally I cannot export it to a FeatureLayer from the WebMap. It is slightly promising because it indicates that it might work if the bug when defining a FeatureLayer source is fixed. I really need to copy the WFS layers into a proper FeatureLayer Collection. You CAN do this easily using Pro! Set up a new WFS server in ArcCatalog, including custom parameters as required, add the layers to the table of contents. Turn off some fields, add more filters, rename layers, load metadata and edit, set up symbology. Change the download limits from 3000 to 100,000. Now just Share to AGOL! Any schema change or new data requires manually replacing the layer, watch out for caches. Now I want to automate this with Python. Particularly in AGOL using a Notebook and a Task. Seems to be possible with the new Pandas SeDF (spatially enabled dataframe) in arcgis package. Not so fast! Loading WFS features into Pandas sdf. This should be easy to do with python requests and geopandas. There are new functions in arcgis to translate from geopandas to sdf and from sdf to a FeatureLayer. You need to import geopandas so that you can read the WFS feed directly into a sdf data frame first. There is a posting noting that you cannot read a WFS feed directly into an Esri sedf. Catch 22 - you cannot import geopandas in a AGOL notebook because it is a Docker instance started up each time. It can work from a Desktop because you can set up a venv that does have geopandas. So how can I install geopandas in AGOL Notebook?
... View more
09-17-2024
03:06 PM
|
0
|
0
|
1978
|
|
POST
|
Well it is possible in ArcGISPro without any python programming. All you do is add a WFS server, tweak the URL, add any cql_filter expressions and get the layers listed. Add these to a map and tweak symbology, visible items and definition queries, layer names etc. Then select all the layers and Share>featurelayer>publish. This will create a better FeatureLayerCollection in AGOL. Why better? Because you can edit, make WebMaps and anything else. The only drawback? It is not dynamic. But wait, neither is WFS usually. The one I have just extracted only updates nightly anyway. So how can you replicate this in Python. In principle duplicate the steps: 1. Use the requests module to set up a request on the WFS endpoint just like the WFS server 2. Download each sublayer as a json extract and move into a Pandas SpatiallyEnabledDataFrame. Not quite so easy in AGOL because the geopandas module is missing. In principle it should work but is not supported directly. But you can copy a geopandas dataframe to an esri spatialdataframe. 3. upload the sdf to AGOL with the GeoAccessor esri extension to arcgis. If the WFS data can be queried for changes you could use the gis.content.edit() functions to just add new records. Don't know about delete records.
... View more
09-15-2024
10:32 PM
|
1
|
0
|
3539
|
|
POST
|
The arcgis python API is a rest interface, not a relational database. Everything is atomic and restful. This means you cannot edit a single attribute in a record. You have to retrieve the whole record, edit the attributes you want and post the whole record back into the online feature layer. Because the REST interface is Stateless. It does not remember anything you have done, which record you edited etc. Its like a whole new phone call to a new support caller without a log. You have to explain the issue all over again. I liken it to having string puppets digging a hole with a shovel instead of you just doing it with a shovel yourself. The puppet is clumsy and very poor at digging holes. You cannot use the arcpy package to edit online data. You have to use the arcgis package.
... View more
09-15-2024
10:14 PM
|
0
|
0
|
1670
|
| Title | Kudos | Posted |
|---|---|---|
| 3 | Tuesday | |
| 1 | 3 weeks ago | |
| 1 | 03-11-2023 03:54 PM | |
| 1 | 09-15-2024 10:32 PM | |
| 1 | 03-12-2026 01:10 AM |
| Online Status |
Offline
|
| Date Last Visited |
Tuesday
|