AsShape
Resumen
Converts GeoJSON objects to ArcPy geometry objects. GeoJSON is a geospatial data interchange format for encoding geographic data structures.
Sintaxis
AsShape (geojson_struct)
| Parámetro | Explicación | Tipo de datos |
geojson_struct |
The geojson_struct includes type and coordinates. type includes the following strings: Point, LineString, Polygon, MultiPoint, and MultiLineString. | Dictionary |
| Tipo de datos | Explicación |
| Object |
AsShape returns a geometry object (PointGeometry, Multipoint, Polyline, or Polygon) based on the input GeoJSON object. import arcpy
gjPoint = {"type": "Point", "coordinates": [5.0, 5.0]}
ptGeometry = arcpy.AsShape(gjPoint)
|
Ejemplo de código
Create a PointGeometry object using a GeoJSON object.
import arcpy
gjPoint = {"type": "Point", "coordinates": [5.0, 5.0]}
ptGeometry = arcpy.AsShape(gjPoint)
Create a Multipoint object using a GeoJSON object.
import arcpy
gjMultiPoint = {
"type": "MultiPoint",
"coordinates": [[5.0, 4.0], [8.0, 7.0]]}
multiPoint = arcpy.AsShape(gjMultiPoint)
Create a Polyline object using a GeoJSON object.
import arcpy
gjLineString = {
"type": "LineString",
"coordinates": [[5.0, 4.0], [8.0, 7.0]]}
polyLine = arcpy.AsShape(gjLineString)
Create a multipart Polyline object using a GeoJSON object.
import arcpy
gjMultiLineString = {
"type": "MultiLineString",
"coordinates": [
[[5.0, 4.0], [8.0, 7.0]],
[[4.0, 5.0], [7.0, 8.0]]]}
mpPolyLine = arcpy.AsShape(gjMultiLineString)
Create a Polygon object using a GeoJSON object.
import arcpy
gjPolygon = {
"type": "Polygon",
"coordinates": [
[[10.0, 0.0], [20.0, 0.0], [20.0, 10.0], [10.0, 10.0], [10.0, 0.0]]]}
polygon = arcpy.AsShape(gjPolygon)
Create a Polygon object using a GeoJSON object.
import arcpy
gjPolygonWithHole = {
"type": "Polygon",
"coordinates": [
[[10.0, 0.0], [20.0, 0.0], [20.0, 10.0], [10.0, 10.0], [10.0, 0.0]],
[[12.0, 2.0], [18.0, 2.0], [18.0, 8.0], [12.0, 8.0], [12.0, 2.0]]]}
polygonWithHole = arcpy.AsShape(gjPolygonWithHole)
7/10/2012