Is there a way to input a GeoPandas DataFrame as FeatureClass into a GDB without using the arcgis module?
I managed to do it in Python (3.7.11) with:
import arcgis # need to eliminate!!!
import arcpy
import os
import pandas as pd
import geopandas as gpd
gdb=r'...\Default.gdb'
my_df = gpd.GeoDataFrame(r.my_df)
my_df.geometry = gpd.points_from_xy(x=pd.DataFrame(my_df.geometry.to_list())[0], y=pd.DataFrame(my_df.geometry.to_list())[1], crs=4326)
my_feature = my_df.spatial.from_geodataframe(my_df[0]) # .spatial.from_geodataframe relies on the arcgis module
...
arcpy.FeatureClassToFeatureClass_conversion(in_features=my_feature, out_path=gdb, out_name="feature_name")
This relies on the arcgis package which I need to avoid though.
As arcpy should be able to handle most everything arcgis did, I hoped to replicate the results from the code above but was unsuccessful.
Using ArcGISBridge in R it is also possible to solve this but as I am confined, using R 4.1.3, this is also not an optimal solution.
Here is a dput() sample of the R data table (it is moved to python using reticulate version 1.22 on a windows 10 OS)
my_df = structure(list(events = c(8L, 7L, 6L, 5L, 5L), geometry = structure(list(
structure(c(16.3378451408185, 48.1906416102795), class = c("XY",
"POINT", "sfg")), structure(c(16.3600388676805, 48.2066526410091
), class = c("XY", "POINT", "sfg")), structure(c(16.3634777044012,
48.2040462780181), class = c("XY", "POINT", "sfg")), structure(c(16.3421793940926,
48.2171604659865), class = c("XY", "POINT", "sfg")), structure(c(16.3389856762508,
48.1969142650631), class = c("XY", "POINT", "sfg"))), class = c("sfc_POINT",
"sfc"), precision = 0, bbox = structure(c(xmin = 16.3378451408185,
ymin = 48.1906416102795, xmax = 16.3634777044012, ymax = 48.2171604659865
), class = "bbox"), crs = structure(list(input = "EPSG:4326",
wkt = "GEOGCRS[\"WGS 84\",\n DATUM[\"World Geodetic System 1984\",\n ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n LENGTHUNIT[\"metre\",1]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n CS[ellipsoidal,2],\n AXIS[\"geodetic latitude (Lat)\",north,\n ORDER[1],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n AXIS[\"geodetic longitude (Lon)\",east,\n ORDER[2],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n USAGE[\n SCOPE[\"Horizontal component of 3D system.\"],\n AREA[\"World.\"],\n BBOX[-90,-180,90,180]],\n ID[\"EPSG\",4326]]"), class = "crs"), n_empty = 0L)), row.names = c(NA,
5L), class = "data.frame")
my_dfto a shapefile and the usesubprocess.call()along with OGR as is shown in the answer here: https://gis.stackexchange.com/questions/121051/can-ogr2ogr-write-data-to-a-file-geodatabase-feature-dataset – rickD Jul 15 '22 at 02:35subprocess.call('ogr2ogr', '-f', '"FileGDB"', 'mygdb.gdb' '~/PathTo/my_df.shp', '-lco', 'FEATURE_DATASET="esri_features"')– rickD Jul 15 '22 at 02:41