|
POST
|
that would be meters squared 10,000m^2 = 1 hectare 1,000,000 m^2 = 1 km^2 etcetera
... View more
Friday
|
1
|
0
|
86
|
|
BLOG
|
Read the help topics... 1 Featureclass To NumPy Array FeatureClassToNumPyArray can be used to pull the vertices out of geometry features. If they are singlepart without holes, then you have an exact representation that can be used to recreate the inputs. If that isn't the case then reconstruction takes some work (see https://github.com/Dan-Patterson/numpy_geometry for the `npg` module). 2 NumPy Array to Featureclass NumPyArrayToFeatureClass will not overwrite an existing feature class, even if the overwriteOutput environment is set to True. ------------------------------ Stepwise... a notebook is attached # ---- Imports
import arcpy
import numpy as np
from numpy.lib.recfunctions import structured_to_unstructured as stu
from numpy.lib.recfunctions import append_fields # like arcpy ExtendTable I will assume that you are using a notebook in ArcGIS Pro. I will demo a simple conversion of polygons to all points. The other options can also be coded for, or simply buy a higher license level of Pro. Assume that your layer is in a map. Specify the layer name and whether you want to carry over extra table fields. # Specify the layer to use for the `lyr_name` variable
# This only works for featureclasses... no further error checking... the pressure is on
#
lyr_name = 'sq3' # -- input the featureclass name
extra_fields = True # -- True keeps all extra fields, False otherwise... just some? write your own Now the big step. check that the layer exists in the active map. If it does, carry on, otherwise bail. the layer datasource and the spatial reference is obtained, a list of fields to dump from the output (lines 11-15) an array is created (lines 16-21). This is a numpy array produced the arcpy.da function designed for this purpose. some cleanup follows, output fields are specified and appended to the output (if any) the output featureclass is created (line 36) and added to the map (line 37) # ---- Project, map and layer collection
# The current project with the active map is checked for the layer name you specified above.
# If it exists, the vertices will be converted to a point featureclass.
#
aprx = arcpy.mp.ArcGISProject("CURRENT")
map_ = aprx.activeMap
lyrs = map_.listLayers(lyr_name)
if lyrs:
in_fc = lyrs[0].dataSource # -- path to the featureclass
SR = arcpy.Describe(in_fc).spatialReference
ignore_flds = ['OBJECTID', 'Shape', 'Shape_Area', 'Shape_Length'] # -- add if you want
keep_flds = ["OID@", "SHAPE@X", "SHAPE@Y"]
if extra_fields:
add_flds = [f.name for f in arcpy.ListFields(in_fc) if f.name not in ignore_flds]
keep_flds = keep_flds + add_flds
arr = arcpy.da.FeatureClassToNumPyArray(
in_fc,
field_names=keep_flds,
spatial_reference=SR,
explode_to_points=True
)
# -- output featureclass checks
out_fc = in_fc + "_pnts"
if arcpy.Exists(out_fc): # -- delete if it exists
arcpy.management.Delete(out_fc)
#
# -- array checks and combining coordinate values
dt_ = arr.dtype
dt_names = [(i[0].replace("@", "_"), i[1]) for i in arr.dtype.descr]
arr.dtype = dt_names
#
final_arr = append_fields(arr, ["Pnt_x", "Pnt_y"], [arr["SHAPE_X"], arr["SHAPE_Y"]])
print("\nOutput fields :\n{}".format(final_arr.dtype.names))
#
# -- produce the output and add to the map.
arcpy.da.NumPyArrayToFeatureClass(final_arr, out_fc, ["SHAPE_X", "SHAPE_Y"], spatial_reference=SR)
map_.addDataFromPath(out_fc) # -- add results to the map
#
else:
print("No layer called {}".format(lyr_name)) And the results are I will spare you the table contents, but they are there. -------------- If you prefer the python window import arcpy
import numpy as np
in_fc = r"C:\...path to your layer...\...layer_name..."
keep_flds = ["OID@", "SHAPE@X", "SHAPE@Y"]
SR = arcpy.Describe(in_fc).spatialReference
arr = arcpy.da.FeatureClassToNumPyArray(
in_fc,
field_names=keep_flds,
spatial_reference=SR,
explode_to_points=True
) Which shows the structured array data format. (snipped to simplify) arr
array([(1, 300009. , 5000001. ), (1, 300000. , 5000000. ),
(1, 300002. , 5000008. ), (1, 300008. , 5000010. ),
... snip
(7, 300004. , 5000009. ), (7, 300002. , 5000009. ),
(7, 300002. , 5000011. )],
dtype=[('OID@', '<i4'), ('SHAPE@X', '<f8'), ('SHAPE@Y', '<f8')]) You can then split the array into its constituent shapes using the OID@ field. Basically determine the difference in the sequential id values, where they differ from 0, get the positional index to use for splitting. spl = np.nonzero(np.diff(arr["OID@"]))[0] + 1 From there, you can produce subarrays subs = np.array_split(arr, spl)
subs[0] # -- the first as an example
array([(1, 300009.000, 5000001.000), (1, 300000.000, 5000000.000),
(1, 300002.000, 5000008.000), (1, 300008.000, 5000010.000),
(1, 300010.000, 5000010.000), (1, 300010.000, 5000008.000),
(1, 300009.000, 5000001.000), (1, 300003.000, 5000003.000),
(1, 300007.000, 5000003.000), (1, 300005.000, 5000007.000),
(1, 300003.000, 5000003.000)],
dtype=[('OID@', '<i4'), ('SHAPE@X', '<f8'), ('SHAPE@Y', '<f8')]) From there you could process to just take the first or last point (one of the main tool options that requires and advanced licence). frst = [i[0] for i in subs] # let's grab the first point of each shape
frst
[(1, 300009.000, 5000001.000),
(2, 300010.000, 5000008.000),
(3, 300008.000, 5000011.000),
(4, 300006.000, 5000012.000),
(5, 300002.500, 5000013.000),
(6, 300004.000, 5000012.500),
(7, 300002.000, 5000011.000)] As a teaser, you can even place a point at a certain percentage along the polygon perimeter with a little numpy magic from numpy.lib.recfunctions import structured_to_unstructured as stu
base = [stu(a[["SHAPE@X", "SHAPE@Y"]]) for a in subs]
halfway = [_percent_along_(a, percent=50) for a in base]
halfway
[array([ 300010.000, 5000009.950]),
array([ 300008.500, 5000012.000]),
array([ 300005.000, 5000010.310]),
array([ 300005.056, 5000014.972]),
array([ 300000.214, 5000010.643]),
array([ 300002.527, 5000012.991]),
array([ 300003.894, 5000009.000])] and the function for placing the points def _percent_along_(a, percent=0):
"""Add a point along a poly feature at a distance from the start point."""
# a = _base_(a)
if percent > 1.:
percent /= 100.
dxdy = a[1:, :] - a[:-1, :] # coordinate differences
leng = np.sqrt(np.einsum('ij,ij->i', dxdy, dxdy)) # segment lengths
cumleng = np.concatenate(([0], np.cumsum(leng)))
perleng = cumleng / cumleng[-1]
if percent <= 0: # check for faulty distance or start point
return a[0]
if percent >= perleng[-1]: # check for greater distance than cumulative
return a[-1]
_end_ = np.digitize(percent, perleng)
x1, y1 = a[_end_]
_start_ = _end_ - 1
x0, y0 = a[_start_]
t = percent - perleng[_start_]
xt = x0 * (1. - t) + (x1 * t)
yt = y0 * (1. - t) + (y1 * t)
return np.array([xt, yt]) Or you can 'arcpy' it if you prefer to crank up Pro. So, basic functionality shouldn't be completely removed by license levels. If you have the need convert features to points, remember that tools are available within.
... View more
Thursday
|
0
|
0
|
104
|
|
POST
|
Calculate Unique Identifier Values Similar to Global IDs perhaps this
... View more
Thursday
|
0
|
0
|
85
|
|
POST
|
cell size * cell count if your raster is in a projected coordinate system, if not... Solved: Calculate the area of a raster dataset with cell s... - Esri Community
... View more
Thursday
|
1
|
2
|
173
|
|
POST
|
There is one that might suit some purposes ArcGIS Arcade Questions - Esri Community
... View more
|
1
|
0
|
106
|
|
POST
|
is it a field mapping issue? Use the Build Frames & Cameras Tables tool—ArcGIS Pro | Documentation
... View more
Thursday
|
0
|
1
|
115
|
|
POST
|
Python Toolbox: parameter data type to access a fi... - Esri Community The field names have a dependency on the input file and on a quick read the setup might be the same as in the code examples. Under Value table parameters there is an example which sets this for the parameter list (eg param1.parameterDependencies = [param0.name] ) Custom toolboxes make this visually easier to setup if you want to experiment with that first
... View more
Wednesday
|
0
|
2
|
153
|
|
POST
|
Weighted Overlay (Spatial Analyst)—ArcGIS Pro | Documentation All integer rasters I assume. same cell size and extent and snap raster? areal extent will obviously affect performance How Weighted Overlay works—ArcGIS Pro | Documentation Are the common preference schemes done ahead of time?
... View more
Wednesday
|
0
|
0
|
139
|
|
POST
|
If it is working for some but not others, then it is either machine specific or user specific. Get the user to try it on a machine that you know someone else had success on. If they can get it to work, then perhaps a soft reset of their machine might work Perform an ArcGIS pro Soft Reset Make sure that the users have no other data in the map when running the tool... that includes basemaps. The first layer added to the map will set the coordinate system for the map and subsequent analysis. PS a google drive link isn't the best option... the camera icon should allow you to post an image within the question (unless new users are restricted for a period of time.)
... View more
Monday
|
0
|
0
|
196
|
|
POST
|
Do you have an image you can share like the one in the help topic? Surface Profile tool returning straight line inste... - Esri Community Is your raster in a projected coordinate system? What are the expected elevation (Z) values when you inspect the raster manually?
... View more
Monday
|
0
|
1
|
241
|
|
POST
|
run check geometry or repair geometry on the featureclass when you are not editing maybe the rings are reversed Check Geometry—ArcGIS Pro | Documentation
... View more
a week ago
|
0
|
0
|
227
|
|
POST
|
Reference requirements may provide some options. maybe mobile map packages Requirements—ArcGIS Field Maps | Documentation
... View more
a week ago
|
0
|
1
|
353
|
|
POST
|
can't find one, but I found a reference to one line labelling strategy that specifies that lines can result in upside down labels Orient line labels to graticules or direction—ArcGIS Pro | Documentation Align labels with line direction, bottom step 10 states... This can be useful if flow arrow symbols are represented by glyphs in fonts and need to be placed in the direction of the line. Note that this option can result in labels being placed upside down.
... View more
a week ago
|
0
|
0
|
155
|
|
POST
|
a quick look at the help topic Use ArcPy in a notebook—ArcGIS Online Help | Documentation To use ArcPy in a notebook, ArcGIS Notebooks must be licensed with the Advanced license, and users must have the privilege to create and run Advanced runtime notebooks.
... View more
a week ago
|
0
|
0
|
117
|
|
IDEA
|
Top right of a post or blog... select Post Options. You can bookmark to your profile. Login to Community, select your Avatar and then My profile. Bookmark links are on the right side. Alternately, Select Printer Friendly Page and print to a pdf using your browser.
... View more
2 weeks ago
|
0
|
0
|
76
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | Thursday | |
| 1 | Friday | |
| 1 | Thursday | |
| 1 | 4 weeks ago | |
| 1 | 4 weeks ago |