Select to view content in your preferred language

Problem with from_featureclass() method parameters

347
2
03-16-2024 10:36 AM
Labels (1)
ChenChen4
New Contributor III

I am following a tutorial at https://developers.arcgis.com/python/guide/part2-data-io-reading-data/

When I use optional parameters from the from_featureclass() method to refine return results, I don't get a subset of the dataset. The full dataset has 3886 rows x 50 columns. It does not matter if I specify the fields parameter or SQL query or where clause, it always return the full dataset:

ChenChen4_0-1710610580232.png

 

Any recommendations? 

 

0 Kudos
2 Replies
Clubdebambos
Occasional Contributor III

Hi @ChenChen4 

What version of the arcgis API are you using? I tested in version 2.2.0.1 and all seems to work as its should. See below in IDE and in Notebook. Maybe try a new notebook and the code below?

 

from arcgis import GIS
import pandas as pd

fc = r"C:\Users\glenb\Documents\Python\sedf_data\cities\cities.shp"

fcls_flds = pd.DataFrame.spatial.from_featureclass(location=fc, fields=["st"])

print(fcls_flds.shape)
>>> (3886, 2)

fcls_whr = pd.DataFrame.spatial.from_featureclass(location=fc, where_clause="st='ID' and pop_class=6")

print(fcls_whr.shape)
>>>(15, 51)

 

Clubdebambos_0-1710612360153.png

 

~ learn.finaldraftmapping.com
0 Kudos
ChenChen4
New Contributor III

Thanks for the quick response. I tried the same code within ArcGIS Pro and it worked, but when I ran it from NB Server it didn't give me the subset.

ChenChen4_1-1710615106783.png

 

I'll do more testing.

 

 

0 Kudos