jlisic / cdlTools

A set of tools for fetching and using the Cropscape Data Layer in R
9 stars 4 forks source link

SSL certificate problem: certificate has expired #19

Closed HNoorazar closed 5 months ago

HNoorazar commented 4 years ago

I am trying to use getCDL like so:

WA_data <- getCDL(x = 53, year=2019, location = "/Users/hn/Documents/")

and I get the error:

  Error in curl::curl_fetch_memory(url, handle = handle) : 
  SSL certificate problem: certificate has expired

Am I doing anything wrong? Cheers, HN

jlisic commented 4 years ago

Try adding ssl.verifypeer = FALSE let me know if that works. The SSL cert seems a bit wonky on cropscape.

HNoorazar commented 4 years ago

Thanks a lot Jonathan,

It did work. However, I have another question. Is there any dataset like this that also includes acreages of each field? I tried (National) data in " https://www.nass.usda.gov/Research_and_Science/Cropland/Release/index.php" But the extensions are .rde and .rdd and .ige. I have not figured out how to read those yet! so, I am not sure if those include acreages.

Thanks, Cheers, Best.

On Tue, Jul 21, 2020 at 6:48 PM Jonathan Lisic notifications@github.com wrote:

Try adding ssl.verifypeer = FALSE let me know if that works. The SSL cert seems a bit wonky on cropscape.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jlisic/cdlTools/issues/19#issuecomment-662194724, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACQMJM6KQUHI4RGYTT2ZTCTR4ZAP5ANCNFSM4PEEOV2A .

jlisic commented 4 years ago

There are some state estimates through quick stats (assuming that is still a thing, I don’t work for USDA anymore). They might even have county estimates. The other way around is to convert pixels to acres. Most of the pixels should be 30m by 30m (you can check this in the raster data). Then just convert square meters to acres.

Jonathan Lisic, Ph.D. Mathematical Statistician Blog: meanmean.me GitHub: www.github.com/jlisic Twitter: twitter.com/jlisic

On Jul 22, 2020, at 4:20 PM, HNoorazar notifications@github.com wrote:

Thanks a lot Jonathan,

It did work. However, I have another question. Is there any dataset like this that also includes acreages of each field? I tried (National) data in " https://www.nass.usda.gov/Research_and_Science/Cropland/Release/index.php" But the extensions are .rde and .rdd and .ige. I have not figured out how to read those yet! so, I am not sure if those include acreages.

Thanks, Cheers, Best.

On Tue, Jul 21, 2020 at 6:48 PM Jonathan Lisic notifications@github.com wrote:

Try adding ssl.verifypeer = FALSE let me know if that works. The SSL cert seems a bit wonky on cropscape.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jlisic/cdlTools/issues/19#issuecomment-662194724, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACQMJM6KQUHI4RGYTT2ZTCTR4ZAP5ANCNFSM4PEEOV2A .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jlisic/cdlTools/issues/19#issuecomment-662675340, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2HT6756Z3VJ3NFFHQ42FTR45CYFANCNFSM4PEEOV2A.

HNoorazar commented 4 years ago

oh great. Thanks. sorry to bother you. I appreciate the help.

Cheers, HN

jlisic commented 4 years ago

No problem, I still maintain the package, I just don’t work there :)

Here is quick stats:

https://quickstats.nass.usda.gov https://quickstats.nass.usda.gov/

Jonathan Lisic, Ph.D. Mathematical Statistician Blog: meanmean.me GitHub: www.github.com/jlisic Twitter: twitter.com/jlisic

On Jul 22, 2020, at 4:38 PM, HNoorazar notifications@github.com wrote:

oh great. Thanks. sorry to bother you. I appreciate the help.

Cheers, HN

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jlisic/cdlTools/issues/19#issuecomment-662683727, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2HT63AW6QRLL4QAH2FH3LR45E3FANCNFSM4PEEOV2A.

melmel49 commented 4 years ago

Yes. In quick stats, you can find state estimates quarterly and country estimates(for many commodities) annually. But those are not necessarily equal to what you get from CDL. I agreed with Jonathan that you can count the pixels and calculate acreages for any geographic location that you are interested in. The resolution of CDL currently is 30mby30m.

Best, Lu

Sent from my iPhone

On Jul 22, 2020, at 4:38 PM, HNoorazar notifications@github.com wrote:

 oh great. Thanks. sorry to bother you. I appreciate the help.

Cheers, HN

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

HNoorazar commented 4 years ago

Thank you, guys. I did not realize they are at pixel level :) That was helpful.

Cheers, HN

Personal Website (https://hnoorazar.com/) https://hnoorazar.com/ LinkedIn (https://www.linkedin.com/in/hnoorazar/) https://www.linkedin.com/in/hnoorazar/ GitHub (https://github.com/HNoorazar/) https://github.com/HNoorazar/

On Wed, Jul 22, 2020 at 1:32 PM Jonathan Lisic notifications@github.com wrote:

There are some state estimates through quick stats (assuming that is still a thing, I don’t work for USDA anymore). They might even have county estimates. The other way around is to convert pixels to acres. Most of the pixels should be 30m by 30m (you can check this in the raster data). Then just convert square meters to acres.

Jonathan Lisic, Ph.D. Mathematical Statistician Blog: meanmean.me GitHub: www.github.com/jlisic Twitter: twitter.com/jlisic

On Jul 22, 2020, at 4:20 PM, HNoorazar notifications@github.com wrote:

Thanks a lot Jonathan,

It did work. However, I have another question. Is there any dataset like this that also includes acreages of each field? I tried (National) data in "

https://www.nass.usda.gov/Research_and_Science/Cropland/Release/index.php" But the extensions are .rde and .rdd and .ige. I have not figured out how to read those yet! so, I am not sure if those include acreages.

Thanks, Cheers, Best.

On Tue, Jul 21, 2020 at 6:48 PM Jonathan Lisic <notifications@github.com

wrote:

Try adding ssl.verifypeer = FALSE let me know if that works. The SSL cert seems a bit wonky on cropscape.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jlisic/cdlTools/issues/19#issuecomment-662194724, or unsubscribe < https://github.com/notifications/unsubscribe-auth/ACQMJM6KQUHI4RGYTT2ZTCTR4ZAP5ANCNFSM4PEEOV2A

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/jlisic/cdlTools/issues/19#issuecomment-662675340>, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AA2HT6756Z3VJ3NFFHQ42FTR45CYFANCNFSM4PEEOV2A .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jlisic/cdlTools/issues/19#issuecomment-662680840, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACQMJM55AXPWNDWXXHBG6JTR45EEBANCNFSM4PEEOV2A .

HNoorazar commented 4 years ago

This is a little disturbing tho. There are only 256 rows in the files I get. It cannot be the case that there are 256 pixels of 30-by-30 in WA. Am I missing something?

download_dir <- "sth here" cdlTools::getCDL(x = 'Washington', year = 2018, location = download_dir, ssl.verifypeer = FALSE)

Cheers, HN

On Wed, Jul 22, 2020 at 1:47 PM Hossein Noorazar h.noorazar.math@gmail.com wrote:

Thank you, guys. I did not realize they are at pixel level :) That was helpful.

Cheers, HN

Personal Website (https://hnoorazar.com/) https://hnoorazar.com/ LinkedIn (https://www.linkedin.com/in/hnoorazar/) https://www.linkedin.com/in/hnoorazar/ GitHub (https://github.com/HNoorazar/) https://github.com/HNoorazar/

On Wed, Jul 22, 2020 at 1:32 PM Jonathan Lisic notifications@github.com wrote:

There are some state estimates through quick stats (assuming that is still a thing, I don’t work for USDA anymore). They might even have county estimates. The other way around is to convert pixels to acres. Most of the pixels should be 30m by 30m (you can check this in the raster data). Then just convert square meters to acres.

Jonathan Lisic, Ph.D. Mathematical Statistician Blog: meanmean.me GitHub: www.github.com/jlisic Twitter: twitter.com/jlisic

On Jul 22, 2020, at 4:20 PM, HNoorazar notifications@github.com wrote:

Thanks a lot Jonathan,

It did work. However, I have another question. Is there any dataset like this that also includes acreages of each field? I tried (National) data in "

https://www.nass.usda.gov/Research_and_Science/Cropland/Release/index.php " But the extensions are .rde and .rdd and .ige. I have not figured out how to read those yet! so, I am not sure if those include acreages.

Thanks, Cheers, Best.

On Tue, Jul 21, 2020 at 6:48 PM Jonathan Lisic < notifications@github.com> wrote:

Try adding ssl.verifypeer = FALSE let me know if that works. The SSL cert seems a bit wonky on cropscape.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jlisic/cdlTools/issues/19#issuecomment-662194724, or unsubscribe < https://github.com/notifications/unsubscribe-auth/ACQMJM6KQUHI4RGYTT2ZTCTR4ZAP5ANCNFSM4PEEOV2A

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/jlisic/cdlTools/issues/19#issuecomment-662675340>, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AA2HT6756Z3VJ3NFFHQ42FTR45CYFANCNFSM4PEEOV2A .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jlisic/cdlTools/issues/19#issuecomment-662680840, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACQMJM55AXPWNDWXXHBG6JTR45EEBANCNFSM4PEEOV2A .

jlisic commented 4 years ago

What does the output look like (also make sure you have rgdal installed). It should look like something like this, from this you:

class : RasterLayer dimensions : 14614, 19759, 288758026 (nrow, ncol, ncell) resolution : 30, 30 (x, y) extent : -2138295, -1545525, 2734185, 3172605 (xmin, xmax, ymin, ymax) crs : +proj=aea +lat_0=23 +lon_0=-96 +lat_1=29.5 +lat_2=45.5 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs source : /private/tmp/CDL_2018_53.tif names : CDL_2018_53 values : 0, 255 (min, max)

a <- cdlTools::getCDL(x = 'Washington', year = 2018, location = download_dir, ssl.verifypeer = FALSE)

you can get counts with table

a_table <- table(raster::getValues(a[[1]])) a_table

   0        1        4        5        6       12       14       21

94290081 1203781 378 2218 20272 96464 12920 282453 23 24 25 27 28 31 32 33 2436812 8503529 703 2055 30190 245832 217 535 35 36 37 38 39 41 42 43 6049 2112770 2031546 447 12219 12579 1030030 817477 44 47 48 49 50 51 52 53 9873 1226 713 138262 38 1228 254352 330673 55 56 57 58 59 61 66 67 122836 235952 66452 4744 298539 7285733 275833 10482 68 69 70 71 76 77 111 112 1292995 546151 124896 694 762 125762 3165600 573017 121 122 123 124 131 141 142 143 5179581 3978333 1706553 493821 3008838 2059848 74924696 3999271 152 176 190 195 205 206 207 208 55399684 7346306 1267917 1053338 55448 24744 12109 522 214 216 219 220 221 222 223 224 2350 2031 21498 539 1036 1107 3100 18 225 226 229 237 242 243 250 639 357 5633 744 177989 1791 9815

you can make a nice data frame then

crop_count <- data.frame( crop = updateNamesCDL(names(a_table)), a_table , stringsAsFactors=FALSE)

Jonathan Lisic, Ph.D. Mathematical Statistician Blog: meanmean.me GitHub: www.github.com/jlisic Twitter: twitter.com/jlisic

On Jul 22, 2020, at 5:25 PM, HNoorazar notifications@github.com wrote:

cdlTools::getCDL(x = 'Washington', year = 2018, location = download_dir, ssl.verifypeer = FALSE)

HNoorazar commented 4 years ago

Good morning Jonathan,

When I did the download command, I received a .dbf file and I read that database file. That file is similar to what you get by using this website: https://nassgeodata.gmu.edu/CropScape/

That file looks like VALUE CLASS_NAME RED GREEN BLUE OPACITY 1: 0 Background 0.00 0.00 0.000 0 2: 1 Corn 1.00 0.82 0.00 1

But what you said is different :)

Thanks again, Cheers, HN

jlisic commented 4 years ago

That’s odd, the dbf files are part of the zip download but raster reads in the geotiff. Everything is pulled from cropscape (the website you listed).

Can you copy and paste your code and if you are using windows/linux/mac etc… and R version, I’ll take a look tonight.

Jonathan Lisic, Ph.D. Mathematical Statistician Blog: meanmean.me GitHub: www.github.com/jlisic Twitter: twitter.com/jlisic

On Jul 23, 2020, at 11:57 AM, HNoorazar notifications@github.com wrote:

Good morning Jonathan,

When I did the download command, I received a .dbf file and I read that database file. That file is similar to what you get by using this website: https://nassgeodata.gmu.edu/CropScape/

That file looks like VALUE CLASS_NAME RED GREEN BLUE OPACITY 1: 0 Background 0.00 0.00 0.000 0 2: 1 Corn 1.00 0.82 0.00 1

But what you said is different :)

Thanks again, Cheers, HN — You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jlisic/cdlTools/issues/19#issuecomment-663088492, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2HT6YZC4NN4RYIHK3TC3LR5BMWVANCNFSM4PEEOV2A.

HNoorazar commented 4 years ago

Sure, I attached the script file. Here is my code (just in case Gmail does not let you open the scrip and detects it as virus or sth!). If there is anything else I can do please let me know.

The R Version is $version.string [1] "R version 3.6.2 (2019-12-12)"

library(foreign) library(data.table) library(dplyr) library(rgdal) library(sp) library(cdlTools) download_dir <- paste0("/Users/hn/Documents/01_research_data/", "remote_sensing/NASS_CDL/download_by_cdlTools/") cdlTools::getCDL(x = 'Washington', year = 2018, location = download_dir, ssl.verifypeer = FALSE) CDL_2019 <- data.table(read.dbf(paste0(download_dir, "/CDL_2019_53.tif.vat.dbf"), as.is=T)) CDL_2019$CLASS_NAME <- tolower(CDL_2019$CLASS_NAME) dim(CDL_2019) CDL_2019 <- CDL_2019[grepl('dbl', CDL_2019$CLASS_NAME), ] dim(CDL_2019)

Cheers, HN

On Thu, Jul 23, 2020 at 9:01 AM Jonathan Lisic notifications@github.com wrote:

That’s odd, the dbf files are part of the zip download but raster reads in the geotiff. Everything is pulled from cropscape (the website you listed).

Can you copy and paste your code and if you are using windows/linux/mac etc… and R version, I’ll take a look tonight.

Jonathan Lisic, Ph.D. Mathematical Statistician Blog: meanmean.me GitHub: www.github.com/jlisic Twitter: twitter.com/jlisic

On Jul 23, 2020, at 11:57 AM, HNoorazar notifications@github.com wrote:

Good morning Jonathan,

When I did the download command, I received a .dbf file and I read that database file. That file is similar to what you get by using this website: https://nassgeodata.gmu.edu/CropScape/

That file looks like VALUE CLASS_NAME RED GREEN BLUE OPACITY 1: 0 Background 0.00 0.00 0.000 0 2: 1 Corn 1.00 0.82 0.00 1

But what you said is different :)

Thanks again, Cheers, HN — You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/jlisic/cdlTools/issues/19#issuecomment-663088492>, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AA2HT6YZC4NN4RYIHK3TC3LR5BMWVANCNFSM4PEEOV2A .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jlisic/cdlTools/issues/19#issuecomment-663090766, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACQMJMYUQYEFZD4MP4BXK73R5BNFZANCNFSM4PEEOV2A .

HNoorazar commented 4 years ago

Jonathan,

It may be totally my fault! This raster thing is new.

Even with your code I am struggling to get a table out of the raster file that includes the CLASS_Name column since I need to figure out the double-cropped pixels.

Cheers, HN

On Thu, Jul 23, 2020 at 9:09 AM Hossein Noorazar h.noorazar.math@gmail.com wrote:

Sure, I attached the script file. Here is my code (just in case Gmail does not let you open the scrip and detects it as virus or sth!). If there is anything else I can do please let me know.

The R Version is $version.string [1] "R version 3.6.2 (2019-12-12)"

library(foreign) library(data.table) library(dplyr) library(rgdal) library(sp) library(cdlTools) download_dir <- paste0("/Users/hn/Documents/01_research_data/", "remote_sensing/NASS_CDL/download_by_cdlTools/") cdlTools::getCDL(x = 'Washington', year = 2018, location = download_dir, ssl.verifypeer = FALSE) CDL_2019 <- data.table(read.dbf(paste0(download_dir, "/CDL_2019_53.tif.vat.dbf"), as.is=T)) CDL_2019$CLASS_NAME <- tolower(CDL_2019$CLASS_NAME) dim(CDL_2019) CDL_2019 <- CDL_2019[grepl('dbl', CDL_2019$CLASS_NAME), ] dim(CDL_2019)

Cheers, HN

On Thu, Jul 23, 2020 at 9:01 AM Jonathan Lisic notifications@github.com wrote:

That’s odd, the dbf files are part of the zip download but raster reads in the geotiff. Everything is pulled from cropscape (the website you listed).

Can you copy and paste your code and if you are using windows/linux/mac etc… and R version, I’ll take a look tonight.

Jonathan Lisic, Ph.D. Mathematical Statistician Blog: meanmean.me GitHub: www.github.com/jlisic Twitter: twitter.com/jlisic

On Jul 23, 2020, at 11:57 AM, HNoorazar notifications@github.com wrote:

Good morning Jonathan,

When I did the download command, I received a .dbf file and I read that database file. That file is similar to what you get by using this website: https://nassgeodata.gmu.edu/CropScape/

That file looks like VALUE CLASS_NAME RED GREEN BLUE OPACITY 1: 0 Background 0.00 0.00 0.000 0 2: 1 Corn 1.00 0.82 0.00 1

But what you said is different :)

Thanks again, Cheers, HN — You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/jlisic/cdlTools/issues/19#issuecomment-663088492>, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AA2HT6YZC4NN4RYIHK3TC3LR5BMWVANCNFSM4PEEOV2A .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jlisic/cdlTools/issues/19#issuecomment-663090766, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACQMJMYUQYEFZD4MP4BXK73R5BNFZANCNFSM4PEEOV2A .

jlisic commented 4 years ago

In the mean time you could check out:

http://meanmean.me/agriculture/r/2016/07/16/The-cdlTools-R-package.html http://meanmean.me/agriculture/r/2016/07/16/The-cdlTools-R-package.html

Jonathan Lisic, Ph.D. Mathematical Statistician Blog: meanmean.me GitHub: www.github.com/jlisic Twitter: twitter.com/jlisic

On Jul 23, 2020, at 12:53 PM, HNoorazar notifications@github.com wrote:

Jonathan,

It may be totally my fault! This raster thing is new.

Even with your code I am struggling to get a table out of the raster file that includes the CLASS_Name column since I need to figure out the double-cropped pixels.

Cheers, HN

On Thu, Jul 23, 2020 at 9:09 AM Hossein Noorazar h.noorazar.math@gmail.com wrote:

Sure, I attached the script file. Here is my code (just in case Gmail does not let you open the scrip and detects it as virus or sth!). If there is anything else I can do please let me know.

The R Version is $version.string [1] "R version 3.6.2 (2019-12-12)"

library(foreign) library(data.table) library(dplyr) library(rgdal) library(sp) library(cdlTools) download_dir <- paste0("/Users/hn/Documents/01_research_data/", "remote_sensing/NASS_CDL/download_by_cdlTools/") cdlTools::getCDL(x = 'Washington', year = 2018, location = download_dir, ssl.verifypeer = FALSE) CDL_2019 <- data.table(read.dbf(paste0(download_dir, "/CDL_2019_53.tif.vat.dbf"), as.is=T)) CDL_2019$CLASS_NAME <- tolower(CDL_2019$CLASS_NAME) dim(CDL_2019) CDL_2019 <- CDL_2019[grepl('dbl', CDL_2019$CLASS_NAME), ] dim(CDL_2019)

Cheers, HN

On Thu, Jul 23, 2020 at 9:01 AM Jonathan Lisic notifications@github.com wrote:

That’s odd, the dbf files are part of the zip download but raster reads in the geotiff. Everything is pulled from cropscape (the website you listed).

Can you copy and paste your code and if you are using windows/linux/mac etc… and R version, I’ll take a look tonight.

Jonathan Lisic, Ph.D. Mathematical Statistician Blog: meanmean.me GitHub: www.github.com/jlisic Twitter: twitter.com/jlisic

On Jul 23, 2020, at 11:57 AM, HNoorazar notifications@github.com wrote:

Good morning Jonathan,

When I did the download command, I received a .dbf file and I read that database file. That file is similar to what you get by using this website: https://nassgeodata.gmu.edu/CropScape/

That file looks like VALUE CLASS_NAME RED GREEN BLUE OPACITY 1: 0 Background 0.00 0.00 0.000 0 2: 1 Corn 1.00 0.82 0.00 1

But what you said is different :)

Thanks again, Cheers, HN — You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/jlisic/cdlTools/issues/19#issuecomment-663088492>, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AA2HT6YZC4NN4RYIHK3TC3LR5BMWVANCNFSM4PEEOV2A .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jlisic/cdlTools/issues/19#issuecomment-663090766, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACQMJMYUQYEFZD4MP4BXK73R5BNFZANCNFSM4PEEOV2A .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jlisic/cdlTools/issues/19#issuecomment-663117128, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2HT63HW4JK3AUHPVUSIE3R5BTKPANCNFSM4PEEOV2A.

HNoorazar commented 4 years ago

Hi Jonathan, How are you?

I do not know if you see anything wrong with the .dbl file I sent earlier or not:

That file looks like VALUE CLASS_NAME RED GREEN BLUE OPACITY 1: 0 Background 0.00 0.00 0.000 0 2: 1 Corn 1.00 0.82 0.00 1

But I made a mistake on my end somehow. The .dbl file has the column CLASS_NAME which is equivalent to the column "crop" in the way you computed the frequency of each crop (pixel counts per crop). I did not realize that earlier. Sorry about that.

Cheers, HN

On Thu, Jul 23, 2020 at 9:58 AM Jonathan Lisic notifications@github.com wrote:

In the mean time you could check out:

http://meanmean.me/agriculture/r/2016/07/16/The-cdlTools-R-package.html < http://meanmean.me/agriculture/r/2016/07/16/The-cdlTools-R-package.html>

Jonathan Lisic, Ph.D. Mathematical Statistician Blog: meanmean.me GitHub: www.github.com/jlisic Twitter: twitter.com/jlisic

On Jul 23, 2020, at 12:53 PM, HNoorazar notifications@github.com wrote:

Jonathan,

It may be totally my fault! This raster thing is new.

Even with your code I am struggling to get a table out of the raster file that includes the CLASS_Name column since I need to figure out the double-cropped pixels.

Cheers, HN

On Thu, Jul 23, 2020 at 9:09 AM Hossein Noorazar < h.noorazar.math@gmail.com> wrote:

Sure, I attached the script file. Here is my code (just in case Gmail does not let you open the scrip and detects it as virus or sth!). If there is anything else I can do please let me know.

The R Version is $version.string [1] "R version 3.6.2 (2019-12-12)"

library(foreign) library(data.table) library(dplyr) library(rgdal) library(sp) library(cdlTools) download_dir <- paste0("/Users/hn/Documents/01_research_data/", "remote_sensing/NASS_CDL/download_by_cdlTools/") cdlTools::getCDL(x = 'Washington', year = 2018, location = download_dir, ssl.verifypeer = FALSE) CDL_2019 <- data.table(read.dbf(paste0(download_dir, "/CDL_2019_53.tif.vat.dbf"), as.is=T)) CDL_2019$CLASS_NAME <- tolower(CDL_2019$CLASS_NAME) dim(CDL_2019) CDL_2019 <- CDL_2019[grepl('dbl', CDL_2019$CLASS_NAME), ] dim(CDL_2019)

Cheers, HN

On Thu, Jul 23, 2020 at 9:01 AM Jonathan Lisic < notifications@github.com> wrote:

That’s odd, the dbf files are part of the zip download but raster reads in the geotiff. Everything is pulled from cropscape (the website you listed).

Can you copy and paste your code and if you are using windows/linux/mac etc… and R version, I’ll take a look tonight.

Jonathan Lisic, Ph.D. Mathematical Statistician Blog: meanmean.me GitHub: www.github.com/jlisic Twitter: twitter.com/jlisic

On Jul 23, 2020, at 11:57 AM, HNoorazar notifications@github.com wrote:

Good morning Jonathan,

When I did the download command, I received a .dbf file and I read that database file. That file is similar to what you get by using this website: https://nassgeodata.gmu.edu/CropScape/

That file looks like VALUE CLASS_NAME RED GREEN BLUE OPACITY 1: 0 Background 0.00 0.00 0.000 0 2: 1 Corn 1.00 0.82 0.00 1

But what you said is different :)

Thanks again, Cheers, HN — You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/jlisic/cdlTools/issues/19#issuecomment-663088492>, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AA2HT6YZC4NN4RYIHK3TC3LR5BMWVANCNFSM4PEEOV2A

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <https://github.com/jlisic/cdlTools/issues/19#issuecomment-663090766 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/ACQMJMYUQYEFZD4MP4BXK73R5BNFZANCNFSM4PEEOV2A

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/jlisic/cdlTools/issues/19#issuecomment-663117128>, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AA2HT63HW4JK3AUHPVUSIE3R5BTKPANCNFSM4PEEOV2A .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jlisic/cdlTools/issues/19#issuecomment-663119321, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACQMJM5IL7WGX5Z7YNB64A3R5BT25ANCNFSM4PEEOV2A .

jlisic commented 4 years ago

I’m not sure why you are using the dbl file, is there a reason why you aren’t using the geotiff?

Jonathan Lisic, Ph.D. Mathematical Statistician Blog: meanmean.me GitHub: www.github.com/jlisic Twitter: twitter.com/jlisic

On Jul 23, 2020, at 8:38 PM, HNoorazar notifications@github.com wrote:

Hi Jonathan, How are you?

I do not know if you see anything wrong with the .dbl file I sent earlier or not:

That file looks like VALUE CLASS_NAME RED GREEN BLUE OPACITY 1: 0 Background 0.00 0.00 0.000 0 2: 1 Corn 1.00 0.82 0.00 1

But I made a mistake on my end somehow. The .dbl file has the column CLASS_NAME which is equivalent to the column "crop" in the way you computed the frequency of each crop (pixel counts per crop). I did not realize that earlier. Sorry about that.

Cheers, HN

On Thu, Jul 23, 2020 at 9:58 AM Jonathan Lisic notifications@github.com wrote:

In the mean time you could check out:

http://meanmean.me/agriculture/r/2016/07/16/The-cdlTools-R-package.html < http://meanmean.me/agriculture/r/2016/07/16/The-cdlTools-R-package.html>

Jonathan Lisic, Ph.D. Mathematical Statistician Blog: meanmean.me GitHub: www.github.com/jlisic Twitter: twitter.com/jlisic

On Jul 23, 2020, at 12:53 PM, HNoorazar notifications@github.com wrote:

Jonathan,

It may be totally my fault! This raster thing is new.

Even with your code I am struggling to get a table out of the raster file that includes the CLASS_Name column since I need to figure out the double-cropped pixels.

Cheers, HN

On Thu, Jul 23, 2020 at 9:09 AM Hossein Noorazar < h.noorazar.math@gmail.com> wrote:

Sure, I attached the script file. Here is my code (just in case Gmail does not let you open the scrip and detects it as virus or sth!). If there is anything else I can do please let me know.

The R Version is $version.string [1] "R version 3.6.2 (2019-12-12)"

library(foreign) library(data.table) library(dplyr) library(rgdal) library(sp) library(cdlTools) download_dir <- paste0("/Users/hn/Documents/01_research_data/", "remote_sensing/NASS_CDL/download_by_cdlTools/") cdlTools::getCDL(x = 'Washington', year = 2018, location = download_dir, ssl.verifypeer = FALSE) CDL_2019 <- data.table(read.dbf(paste0(download_dir, "/CDL_2019_53.tif.vat.dbf"), as.is=T)) CDL_2019$CLASS_NAME <- tolower(CDL_2019$CLASS_NAME) dim(CDL_2019) CDL_2019 <- CDL_2019[grepl('dbl', CDL_2019$CLASS_NAME), ] dim(CDL_2019)

Cheers, HN

On Thu, Jul 23, 2020 at 9:01 AM Jonathan Lisic < notifications@github.com> wrote:

That’s odd, the dbf files are part of the zip download but raster reads in the geotiff. Everything is pulled from cropscape (the website you listed).

Can you copy and paste your code and if you are using windows/linux/mac etc… and R version, I’ll take a look tonight.

Jonathan Lisic, Ph.D. Mathematical Statistician Blog: meanmean.me GitHub: www.github.com/jlisic Twitter: twitter.com/jlisic

On Jul 23, 2020, at 11:57 AM, HNoorazar notifications@github.com wrote:

Good morning Jonathan,

When I did the download command, I received a .dbf file and I read that database file. That file is similar to what you get by using this website: https://nassgeodata.gmu.edu/CropScape/

That file looks like VALUE CLASS_NAME RED GREEN BLUE OPACITY 1: 0 Background 0.00 0.00 0.000 0 2: 1 Corn 1.00 0.82 0.00 1

But what you said is different :)

Thanks again, Cheers, HN — You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/jlisic/cdlTools/issues/19#issuecomment-663088492>, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AA2HT6YZC4NN4RYIHK3TC3LR5BMWVANCNFSM4PEEOV2A

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <https://github.com/jlisic/cdlTools/issues/19#issuecomment-663090766 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/ACQMJMYUQYEFZD4MP4BXK73R5BNFZANCNFSM4PEEOV2A

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/jlisic/cdlTools/issues/19#issuecomment-663117128>, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AA2HT63HW4JK3AUHPVUSIE3R5BTKPANCNFSM4PEEOV2A .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jlisic/cdlTools/issues/19#issuecomment-663119321, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACQMJM5IL7WGX5Z7YNB64A3R5BT25ANCNFSM4PEEOV2A .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jlisic/cdlTools/issues/19#issuecomment-663298744, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2HT65LWNJFZFAIHB252SDR5DJXXANCNFSM4PEEOV2A.

HNoorazar commented 4 years ago

Because I was familiar with .dbf file, but did not know about GEOTIFF or raster.

I must forget about the .dbf since it does not have what I want, and with your kind help (and bad .dbf file :D ) I think the raster file includes what I was looking for and that is what I have to do :)

Cheers, Hossein

On Fri, Jul 24, 2020 at 10:55 AM Jonathan Lisic notifications@github.com wrote:

I’m not sure why you are using the dbl file, is there a reason why you aren’t using the geotiff?

Jonathan Lisic, Ph.D. Mathematical Statistician Blog: meanmean.me GitHub: www.github.com/jlisic Twitter: twitter.com/jlisic

On Jul 23, 2020, at 8:38 PM, HNoorazar notifications@github.com wrote:

Hi Jonathan, How are you?

I do not know if you see anything wrong with the .dbl file I sent earlier or not:

That file looks like VALUE CLASS_NAME RED GREEN BLUE OPACITY 1: 0 Background 0.00 0.00 0.000 0 2: 1 Corn 1.00 0.82 0.00 1

But I made a mistake on my end somehow. The .dbl file has the column CLASS_NAME which is equivalent to the column "crop" in the way you computed the frequency of each crop (pixel counts per crop). I did not realize that earlier. Sorry about that.

Cheers, HN

On Thu, Jul 23, 2020 at 9:58 AM Jonathan Lisic <notifications@github.com

wrote:

In the mean time you could check out:

http://meanmean.me/agriculture/r/2016/07/16/The-cdlTools-R-package.html <

http://meanmean.me/agriculture/r/2016/07/16/The-cdlTools-R-package.html>

Jonathan Lisic, Ph.D. Mathematical Statistician Blog: meanmean.me GitHub: www.github.com/jlisic Twitter: twitter.com/jlisic

On Jul 23, 2020, at 12:53 PM, HNoorazar notifications@github.com wrote:

Jonathan,

It may be totally my fault! This raster thing is new.

Even with your code I am struggling to get a table out of the raster file that includes the CLASS_Name column since I need to figure out the double-cropped pixels.

Cheers, HN

On Thu, Jul 23, 2020 at 9:09 AM Hossein Noorazar < h.noorazar.math@gmail.com> wrote:

Sure, I attached the script file. Here is my code (just in case Gmail does not let you open the scrip and detects it as virus or sth!). If there is anything else I can do please let me know.

The R Version is $version.string [1] "R version 3.6.2 (2019-12-12)"

library(foreign) library(data.table) library(dplyr) library(rgdal) library(sp) library(cdlTools) download_dir <- paste0("/Users/hn/Documents/01_research_data/", "remote_sensing/NASS_CDL/download_by_cdlTools/") cdlTools::getCDL(x = 'Washington', year = 2018, location = download_dir, ssl.verifypeer = FALSE) CDL_2019 <- data.table(read.dbf(paste0(download_dir, "/CDL_2019_53.tif.vat.dbf"), as.is=T)) CDL_2019$CLASS_NAME <- tolower(CDL_2019$CLASS_NAME) dim(CDL_2019) CDL_2019 <- CDL_2019[grepl('dbl', CDL_2019$CLASS_NAME), ] dim(CDL_2019)

Cheers, HN

On Thu, Jul 23, 2020 at 9:01 AM Jonathan Lisic < notifications@github.com> wrote:

That’s odd, the dbf files are part of the zip download but raster reads in the geotiff. Everything is pulled from cropscape (the website you listed).

Can you copy and paste your code and if you are using windows/linux/mac etc… and R version, I’ll take a look tonight.

Jonathan Lisic, Ph.D. Mathematical Statistician Blog: meanmean.me GitHub: www.github.com/jlisic Twitter: twitter.com/jlisic

On Jul 23, 2020, at 11:57 AM, HNoorazar < notifications@github.com> wrote:

Good morning Jonathan,

When I did the download command, I received a .dbf file and I read that database file. That file is similar to what you get by using this website: https://nassgeodata.gmu.edu/CropScape/

That file looks like VALUE CLASS_NAME RED GREEN BLUE OPACITY 1: 0 Background 0.00 0.00 0.000 0 2: 1 Corn 1.00 0.82 0.00 1

But what you said is different :)

Thanks again, Cheers, HN — You are receiving this because you commented. Reply to this email directly, view it on GitHub <

https://github.com/jlisic/cdlTools/issues/19#issuecomment-663088492>, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AA2HT6YZC4NN4RYIHK3TC3LR5BMWVANCNFSM4PEEOV2A

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub < https://github.com/jlisic/cdlTools/issues/19#issuecomment-663090766 , or unsubscribe <

https://github.com/notifications/unsubscribe-auth/ACQMJMYUQYEFZD4MP4BXK73R5BNFZANCNFSM4PEEOV2A

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/jlisic/cdlTools/issues/19#issuecomment-663117128>, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AA2HT63HW4JK3AUHPVUSIE3R5BTKPANCNFSM4PEEOV2A

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jlisic/cdlTools/issues/19#issuecomment-663119321, or unsubscribe < https://github.com/notifications/unsubscribe-auth/ACQMJM5IL7WGX5Z7YNB64A3R5BT25ANCNFSM4PEEOV2A

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/jlisic/cdlTools/issues/19#issuecomment-663298744>, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AA2HT65LWNJFZFAIHB252SDR5DJXXANCNFSM4PEEOV2A .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jlisic/cdlTools/issues/19#issuecomment-663659804, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACQMJM7NCRQJ7PSGPC5TGNDR5HDKXANCNFSM4PEEOV2A .