Git Product home page Git Product logo

Comments (5)

mmann1123 avatar mmann1123 commented on May 24, 2024

Tracked down the row that was giving me trouble:

(IPdb [3]): dfrow
R_NAME                                                   SNNP
R_CODE                                                      7
Z_NAME                                    Derashe Lyiu Wereda
Z_CODE                                                    716
W_NAME                                        Derashe Special
W_CODE                                                  71601
KK_NAME                                                  None
KK_CODE                                                     0
Remark                                                   None
T_NAME                                                   None
T_CODE                                                      0
RK_NAME                                                 Onota
RK_CODE                                            71601010.0
EA_NAME                                                010-04
UK_NAME                                                  None
UK_CODE                                                  None
EA_ID                                                    None
UK_ID                                                    None
EA_CODE                                                     4
W_code_t                                               071601
KK_cd_T                                                  None
RK_Code1                                                 None
FID                                                      4714
id                                                       4715
geometry    POLYGON ((37.49745968170024 5.653699819037462,...
Name: 4714, dtype: object

(IPdb [4]): sample_feature(dfrow,
                                          id_column,
                                          df_columns,
                                          data.crs,
                                          data.res,
                                          all_touched,
                                          meta,
                                          frac,
                                          min_frac_area)
*** ValueError: cannot set a frame with no defined index and a scalar

from geowombat.

mmann1123 avatar mmann1123 commented on May 24, 2024

In sample_feature1 seems like rasterize` is returning an empty array...

 feature_array = features.rasterize([geom],
                                           out_shape=geom_info.shape,
                                           fill=0,
                                           out=None,
                                           transform=geom_info.affine,
                                           all_touched=all_touched,
                                           default_value=1,
                                           dtype='int32')
                                           

feature_array
array([[0]], dtype=int32)

That creates an empty geodataframe

fea_df = gpd.GeoDataFrame(data=np.c_[fid_, np.arange(0, n_samples)],
                              geometry=gpd.points_from_xy(x_coords, y_coords),
                              crs=crs,
                              columns=[id_column, 'point'])

fea_df
Empty GeoDataFrame
Columns: [id, point, geometry]
Index: []

So then transferring column data back throws an error:

for col in other_cols:
        fea_df.loc[:, col] = df_row[col]
        
*** ValueError: cannot set a frame with no defined index and a scalar

One possible solution

if not fea_df.empty:
        for col in other_cols:
            fea_df.loc[:, col] = df_row[col]
    else:
        pass

Although not sure if you prefer a try except...

from geowombat.

mmann1123 avatar mmann1123 commented on May 24, 2024

@jgrss I am running into issues with gw.extract again. I think its related to the issue above. Just wondering if we have any thoughts on a solution

from geowombat.

jgrss avatar jgrss commented on May 24, 2024

@mmann1123 have you tested this proposed solution?

if not fea_df.empty:
        for col in other_cols:
            fea_df.loc[:, col] = df_row[col]
    else:
        pass

I would be happy with this.

from geowombat.

mmann1123 avatar mmann1123 commented on May 24, 2024

@mmann1123 have you tested this proposed solution?

@jgrss Yes this solves the issue for me. I've tested it in a few different scenarios

from geowombat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.