r-spatial / sf

Simple Features for R
https://r-spatial.github.io/sf/
Other
1.35k stars 299 forks source link

Error in UseMethod("st_write") : no applicable method for 'st_write' applied to an object of class "list" #2332

Closed KathanEcol1 closed 9 months ago

KathanEcol1 commented 9 months ago

st_write(spdf,dsn = "C:/Users/HP/Desktop/sr", layer = 'test', driver="ESRI Shapefile" )

Error in UseMethod("st_write") : no applicable method for 'st_write' applied to an object of class "list"

rsbivand commented 9 months ago

What is class(spdf)?

KathanEcol1 commented 9 months ago

List

Get Outlook for iOShttps://aka.ms/o0ukef


From: Roger Bivand @.> Sent: Tuesday, February 6, 2024 12:43:22 PM To: r-spatial/sf @.> Cc: Kathan Bandyopadhyay @.>; Author @.> Subject: Re: [r-spatial/sf] Error in UseMethod("st_write") : no applicable method for 'st_write' applied to an object of class "list" (Issue #2332)

◆ This message was sent from a non-UWYO address. Please exercise caution when clicking links or opening attachments from external sources.

What is class(spdf)?

— Reply to this email directly, view it on GitHubhttps://github.com/r-spatial/sf/issues/2332#issuecomment-1928909532, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AZQWE7SWULSM76ZKLYW32YLYSHJZFAVCNFSM6AAAAABC3MTMWWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMRYHEYDSNJTGI. You are receiving this because you authored the thread.Message ID: @.***>

Nowosad commented 9 months ago

@KathanEcol1 -- the first object in st_write() must be an sf object, not a list.

KathanEcol1 commented 9 months ago

How to export shapefile from a list

Get Outlook for iOShttps://aka.ms/o0ukef


From: Jakub Nowosad @.> Sent: Tuesday, February 6, 2024 1:51:22 PM To: r-spatial/sf @.> Cc: Kathan Bandyopadhyay @.>; Mention @.> Subject: Re: [r-spatial/sf] Error in UseMethod("st_write") : no applicable method for 'st_write' applied to an object of class "list" (Issue #2332)

◆ This message was sent from a non-UWYO address. Please exercise caution when clicking links or opening attachments from external sources.

@KathanEcol1https://github.com/KathanEcol1 -- the first object in st_write() must be an sf object, not a list.

— Reply to this email directly, view it on GitHubhttps://github.com/r-spatial/sf/issues/2332#issuecomment-1928996180, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AZQWE7R2SN4IUBYSGBO55UTYSHRYFAVCNFSM6AAAAABC3MTMWWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMRYHE4TMMJYGA. You are receiving this because you were mentioned.Message ID: @.***>

Nowosad commented 9 months ago

Where does your list come from? How did you create it?

(Here, you are trying to use the sf package, which creates, operates, and saves sf objects -- see, for example, https://r-spatial.github.io/sf/articles/sf2.html)

rsbivand commented 9 months ago

What is sapply(spdf, class) to list the classes of objects in the list?

My suspicion is that spdf is a SpatialPointsDataFrame or a SpatialPolygonsDataFrame, but reports as a list. We need to see the code creating spdf.

KathanEcol1 commented 9 months ago

spdf <- fxi.contour(mod.0, i = 1:23, plt = FALSE, p = c(0.5,0.95),nx = 256, SPDF = TRUE, fitmode = TRUE)

Mod.0 is the top model from SECR analysis.

Get Outlook for iOShttps://aka.ms/o0ukef


From: Roger Bivand @.> Sent: Tuesday, February 6, 2024 1:55:30 PM To: r-spatial/sf @.> Cc: Kathan Bandyopadhyay @.>; Mention @.> Subject: Re: [r-spatial/sf] Error in UseMethod("st_write") : no applicable method for 'st_write' applied to an object of class "list" (Issue #2332)

◆ This message was sent from a non-UWYO address. Please exercise caution when clicking links or opening attachments from external sources.

What is sapply(spdf, class) to list the classes of objects in the list?

My suspicion is that spdf is a SpatialPointsDataFrame or a SpatialPolygonsDataFrame, but reports as a list. We need to see the code creating spdf.

— Reply to this email directly, view it on GitHubhttps://github.com/r-spatial/sf/issues/2332#issuecomment-1929002099, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AZQWE7WJTEIWTSKX5WXLIUTYSHSHVAVCNFSM6AAAAABC3MTMWWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMRZGAYDEMBZHE. You are receiving this because you were mentioned.Message ID: @.***>

Nowosad commented 9 months ago

Based on this function documentation, you need to use the output = 'sf' argument in the fxi.contour function, before using st_write().