Пример #1
0
def sdf_from_xyz(df, x_col, y_col, z_col=None, sr=None):
    """builds a SpatialDataFrame from DataFrame with
    x, y, and z columns
    
    args:
    df - the dataframe
    x_col - the dataframe column corresponding to x coordinate
    y_col - the dataframe column corresponding to y coordinate
    z_col - optional, the dataframe column corresponding to z coordinate
    sr - the spatial reference for the spatial data frame
    """

    if not z_col:
        return SpatialDataFrame.from_xy(df, x_col, y_col, sr)

    def point_for_row(x, y, z, sr):
        return Point({'x': x, 'y': y, 'z': z, "spatialReference": sr})

    if sr is None:
        sr = SpatialReference({'wkid': 4326})

    df_geom = df.apply(
        lambda row: point_for_row(row[x_col], row[y_col], row[z_col], sr),
        axis=1)
    return SpatialDataFrame(data=df, geometry=df_geom, sr=sr)
Пример #2
0
from arcgis import GIS
import pandas as pd
from arcgis.features import GeoAccessor, GeoSeriesAccessor
from arcgis.geocoding import batch_geocode
from arcgis.features import SpatialDataFrame

gis = GIS('https://siarcgisweb01.trssllc.com/portal/home', 'sazdrake')

map1 = gis.map('New York, NY')
map1.basemap = "osm"
map1

address_frame = pd.read_csv('data/city_of_new_york.csv')

address_shp = SpatialDataFrame.from_xy(address_frame, 'LON', 'LAT')

address_shp.spatial.plot(map_widget=map1)
Пример #3
0
#%%
df.to_csv(custAcctFile,header=False, index=True)

#%% [markdown]
# [```gis.features.SpatialDataFrame()```](https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.features.toc.html?highlight=spatialdataframe#arcgis.features.SpatialDataFrame.from_xy)

#%%
from arcgis.features import SpatialDataFrame
from arcgis.gis import GIS
from getpass import getpass
from IPython.display import display


#%%
sdf = SpatialDataFrame.from_xy(df,"POINT_X","POINT_Y")
gis = GIS(arcpy.GetActivePortalURL(), username=input("Enter User Name "), password=(getpass()))
#gis = GIS()
#portalDesc = arcpy.GetPortalDescription()
# search and list all items owned by connected user
#query=f'owner:{portalDesc["user"]["username"]} AND title:CW BaseMap'
#itemType="Feature Layer"
#sortField="title"
#sortOrder="asc"
# default max__items is 10
#maxItems=100
#m = gis.content.search(query,itemType,sortField,sortOrder,maxItems)


#%%
consumptionLyr = gis.content.import_data(sdf)