美国农业部 2015-2022 年作物序列边界
美国农业部 2015-2022 年作物序列边界
作物序列边界(CSB)是与美国农业部经济研究局合作开发的,它提供了美国毗连地区的田间边界、作物种植面积和作物轮作的估计数据。该数据集利用卫星图像和其他公共数据,并且是开放源码的,使用户能够对美国种植的商品进行面积和统计分析。它为农民的种植决策和实践提供了宝贵的见解。前言 – 人工智能教程
NASS 需要一个有代表性的田间数据集来预测玉米-大豆等常见轮作的作物种植情况,而经济研究局 (ERS) 则利用 CSB 来研究耕作和覆盖种植等农场管理方法随时间推移而发生的变化。CSB 数据集代表特定时间范围内的非机密单一作物田边界。它不包括个人身份信息、所有权边界或地块。数据来源于卫星图像和公开信息,不包括生产者或农业服务局等机构提供的信息。如需访问和了解更多信息,请访问 CSB 网站。访问 CSB GitHub 代码库,查看与数据集相关的元数据。
作物序列边界 (CSB) 代表地理空间算法生成的田间多边形,源自 NASS 耕地数据层 (CDL)。这些多边形实体满足了依赖网格数据集的应用需求,需要分析单位来简化数据汇总。CSB 的主要目标是提供横跨美国 48 个毗连区的全面覆盖范围,确保多年数据的精确性和可复制性。这些结构是通过合并特定时间范围内的历史 CDL 而形成的,同时还整合了公路和铁路网络,以准确描绘这些模拟田地内的作物序列。该数据集适用于 2015 年至 2022 年的生长季节。
引用Citations¶
Hunt, Kevin A., Jonathon Abernethy, Peter Beeson, Maria Bowman, Steven Wallander, and Ryan Williams. "Crop Sequence Boundaries (CSB): Delineated
Fields Using Remotely Sensed Crop Rotations."
Abernethy, Jonathon, Peter Beeson, Claire Boryan, Kevin Hunt, and Luca Sartore. "Preseason crop type prediction using crop sequence boundaries." Computers and Electronics in Agriculture 208 (2023): 107768.
数据结构和处理过程Dataset strucutre and preprocessing¶
这些数据集作为地球引擎中的特征集合提供给每个州,1522 个特征集合代表了 2015-2022 年的生长季节。州名是特征集合名称的一部分。虽然没有必要,但可以将它们合并为一个数据集,我创建了这个数据集,供那些希望在合并后的特征数据集上进行分析的人使用。
代码Earth Engine Snippet: Source¶
var csbal22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBAL1522");
var csbar22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBAR1522");
var csbaz22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBAZ1522");
var csbca22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBCA1522");
var csbco22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBCO1522");
var csbct22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBCT1522");
var csbde22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBDE1522");
var csbga22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBGA1522");
var csbfl22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBFL1522");
var csbia22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBIA1522");
var csbid22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBID1522");
var csbil22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBIL1522");
var csbin22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBIN1522");
var csbks22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBKS1522");
var csbky22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBKY1522");
var csbla22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBLA1522");
var csbma22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBMA1522");
var csbmd22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBMD1522");
var csbme22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBME1522");
var csbmi22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBMI1522");
var csbmn22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBMN1522");
var csbmo22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBMO1522");
var csbms22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBMS1522");
var csbmt22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBMT1522");
var csbne22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBNE1522");
var csbnh22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBNH1522");
var csbnj22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBNJ1522");
var csbnm22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBNM1522");
var csbnv22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBNV1522");
var csbny22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBNY1522");
var csbnc22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBNC1522");
var csbnd22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBND1522");
var csboh22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBOH1522");
var csbok22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBOK1522");
var csbor22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBOR1522");
var csbpa22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBPA1522");
var csbri22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBRI1522");
var csbsc22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBSC1522");
var csbsd22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBSD1522");
var csbtn22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBTN1522");
var csbtx22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBTX1522");
var csbut22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBUT1522");
var csbvt22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBVT1522");
var csbva22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBVA1522");
var csbwa22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBWA1522");
var csbwv22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBWV1522");
var csbwi22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBWI1522");
var csbwy22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBWY1522");
代码合并后Earth Engine Snippet Combined¶
var combined_csb= ee.FeatureCollection('projects/sat-io/open-datasets/USDA/CSB_1522');
///////////////////////////////////////////////////////////////////////////////////
/////$$$$$$$///////// Create menus for states and counties ////////$$$$$$/////////
////////////////////---------- Author: Dr. Zhe Li -------------////////////////////
///////////////=================== USDA NASS SARS ===================/////////////
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
//////////////$$$$$$$///////// Host and Query CSBs ////////$$$$$$/////////////////
////////////////////---------- Author: Arthur Rosales -------------////////////////
///////////////=================== USDA NASS SARS ===================/////////////
///////////////////////////////////////////////////////////////////////////////////
/*Global Variable*/
var csb22;
var empty1;
var fills1;
var filledOutlines1;
var empty2;
var fills2;
var image1;
/*---------------------LOAD State and County features ----------------------------*/
var us_states = ee.FeatureCollection("TIGER/2018/States"),
counties = ee.FeatureCollection("TIGER/2018/Counties");
/*-----------------------LOAD CSB FILES FROM ASSETS ------------------------------*/
var styling = {color: 'red', fillColor: '00000000', width: 2};
var styling_co = {color: 'white', fillColor: '00000000', width: 0.5};
var csbal22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBAL1522");
var csbar22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBAR1522");
var csbaz22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBAZ1522");
var csbca22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBCA1522");
var csbco22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBCO1522");
var csbct22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBCT1522");
var csbde22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBDE1522");
var csbga22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBGA1522");
var csbfl22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBFL1522");
var csbia22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBIA1522");
var csbid22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBID1522");
var csbil22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBIL1522");
var csbin22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBIN1522");
var csbks22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBKS1522");
var csbky22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBKY1522");
var csbla22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBLA1522");
var csbma22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBMA1522");
var csbmd22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBMD1522");
var csbme22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBME1522");
var csbmi22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBMI1522");
var csbmn22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBMN1522");
var csbmo22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBMO1522");
var csbms22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBMS1522");
var csbmt22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBMT1522");
var csbne22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBNE1522");
var csbnh22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBNH1522");
var csbnj22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBNJ1522");
var csbnm22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBNM1522");
var csbnv22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBNV1522");
var csbny22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBNY1522");
var csbnc22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBNC1522");
var csbnd22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBND1522");
var csboh22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBOH1522");
var csbok22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBOK1522");
var csbor22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBOR1522");
var csbpa22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBPA1522");
var csbri22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBRI1522");
var csbsc22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBSC1522");
var csbsd22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBSD1522");
var csbtn22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBTN1522");
var csbtx22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBTX1522");
var csbut22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBUT1522");
var csbvt22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBVT1522");
var csbva22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBVA1522");
var csbwa22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBWA1522");
var csbwv22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBWV1522");
var csbwi22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBWI1522");
var csbwy22 = ee.FeatureCollection("projects/nass-csb/assets/csb1522/CSBWY1522");
var istate= {
Alabama: [csbal22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "01", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Arkansas: [csbar22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "05", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Arizona: [csbaz22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "04", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
California: [csbca22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "06", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Colorado: [csbco22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "08", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Connecticut: [csbct22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "09", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Delaware: [csbde22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "10", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Florida: [csbfl22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "12", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Georgia: [csbga22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "13", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Iowa: [csbia22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "19", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Idaho: [csbid22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "16", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Illinois: [csbil22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "17", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Indiana: [csbin22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "18", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Kansas: [csbks22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "20", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Kentucky: [csbky22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "21", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Louisiana: [csbla22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "22", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Massachusetts : [csbma22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "25", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Maryland : [csbmd22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "24", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Maine : [csbme22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "23", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Michigan : [csbmi22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "26", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Minnesota : [csbmn22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "27", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Missouri : [csbmo22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "29", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Mississippi : [csbms22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "28", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Montana : [csbmt22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "30", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Nebraska : [csbne22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "31", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
'New Hampshire' : [csbnh22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "33", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
'New Jersey' : [csbnj22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "34", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
'New Mexico' : [csbnm22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "35", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Nevada : [csbnv22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "32", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
'New York' : [csbny22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "36", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
'North Carolina' : [csbnc22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "37", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
'North Dakota' : [csbnd22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "38", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Ohio : [csboh22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "39", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Oklahoma : [csbok22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "40", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Oregon : [csbor22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "41", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Pennsylvania : [csbpa22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "42", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
'Rhode Island' : [csbri22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "44", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
'South Carolina' : [csbsc22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "45", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
'South Dakota' : [csbsd22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "46", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Tennessee : [csbtn22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "47", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Texas : [csbtx22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "48", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Utah : [csbut22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "49", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Vermont : [csbvt22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "50", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Virginia : [csbva22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "51", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Washington : [csbwa22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "53", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
'West Virginia' : [csbwv22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "54", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Wisconsin : [csbwi22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "55", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15'],
Wyoming : [csbwy22,'R22','R21','R20','R19','R18','R17','R16','R15',2022, "56", 'ACRES','CROP22','CROP21','CROP20','CROP19','CROP18','CROP17','CROP16','CROP15']
};
var keys = Object.keys(istate);
/*----------------------Define variables for dropdown----------------------------*/
var state_name = '';
var state_FP_selected = '';
var state_selected = us_states.first();
var county_name = 'Not selected';
var county_selected = counties.first();
var shp_us_counties = ee.FeatureCollection(counties);
var AOI = state_selected;
var empty = ee.Image().byte();
var state_outline_lyr = ui.Map.Layer();
var county_outline_lyr = ui.Map.Layer();
var inset_county_outline_lyr = ui.Map.Layer();
var csblayer = ui.Map.Layer();
/*--------------------------Define Component Panels--------------------------------*/
var mapPanel = ui.Map().setOptions('SATELLITE'); //// Set map layer as setellite images
mapPanel.setCenter(-98.36, 39.89, 5); //// CONUS
mapPanel.style().set('cursor', 'crosshair');
mapPanel.setControlVisibility(false);
mapPanel.setControlVisibility({zoomControl: true});
var layers = mapPanel.layers();
var insetmap = ui.Map().setCenter(-94.625, 42, 5);
var insetlayers=insetmap.layers();
/*new*/
//var bounds = ee.Geometry.Rectangle(mapPanel.getBounds());
//insetmap.centerObject(bounds);
/*end new*/
insetmap.setControlVisibility(false);
insetmap.setControlVisibility({zoomControl: true});
insetmap.setControlVisibility(false);
ui.Map.Linker([mapPanel, insetmap],"change-center");
var Panel = ui.Panel({style: {width: '30%', }});
var selectorLabel = ui.Label("1. Set State and County to Load Data...", {fontWeight: 'bold', fontSize: '1em'});
Panel.add(selectorLabel);
var Label_selectState = ui.Label({value: 'Select a state:',
style: {fontSize: '12px', }
});
var dropdown_menu_states = ui.Select({placeholder: ' ',
style: {width: '100px'},
items: keys
});
/*var statesNames = us_states.aggregate_array('NAME').sort();*/
var statesNames = ee.List(keys);
statesNames = statesNames.insert(0, ' ');
/*statesNames = statesNames.insert(0, ' ');*/
statesNames.evaluate(function(states){
dropdown_menu_states.items().reset(states);
dropdown_menu_states.style().set({width: '200px',});
});
var Panel_selectState = ui.Panel({
widgets: [Label_selectState, dropdown_menu_states],
layout: ui.Panel.Layout.Flow('horizontal'),
style: {stretch: 'horizontal'}
});
Panel.add(Panel_selectState);
var Label_selectCounty = ui.Label({value: 'Select a county:',
style: {fontSize: '12px', }
});
var dropdown_menu_counties = ui.Select({placeholder: ' ',});
dropdown_menu_counties.style().set({width: '100px',});
var Panel_selectCounty = ui.Panel({
widgets: [Label_selectCounty, dropdown_menu_counties],
layout: ui.Panel.Layout.Flow('horizontal'), //// Default is 'vertical'
style: {stretch: 'horizontal'}
});
Panel.add(Panel_selectCounty);
var analysisLabel = ui.Label("2. Click Map for Analysis", {fontWeight: 'bold', fontSize: '1em'});
Panel.add(analysisLabel);
var analysisLabel2 = ui.Label('Please be patient after each click.');
Panel.add(analysisLabel2);
var header = ui.Label('Summary:');
//var analysisPanel=ui.Panel([header],"flow");
var analysisPanel=ui.Panel();
analysisPanel.style().set('backgroundColor', 'lightgray');
Panel.add(analysisPanel);
var infoLabel = ui.Label("3. More Info and Downloads", {fontWeight: 'bold', fontSize: '1em'});
var infoLink = ui.Label('USDA NASS/ERS Crop Sequence Boundaries', {color: 'blue'},'https://www.nass.usda.gov/Research_and_Science/Crop-Sequence-Boundaries/');
Panel.add(infoLabel);
Panel.add(infoLink);
// set position of panel
var legend = ui.Panel({
style: {
position: 'bottom-left',
padding: '8px 15px'
}
});
// Create legend title
var legendTitle = ui.Label({
value: 'Legend for Select Crops',
style: {
fontWeight: 'bold',
fontSize: '.75em',
margin: '0 0 4px 0',
padding: '0'
}
});
// Add the title to the panel
legend.add(legendTitle);
// Creates and styles 1 row of the legend.
var makeRow = function(color, name) {
// Create the label that is actually the colored box.
var colorBox = ui.Label({
style: {
backgroundColor: '#' + color,
// Use padding to give the box height and width.
padding: '8px',
margin: '0 0 4px 0'
}
});
// Create the label filled with the description text.
var description = ui.Label({
value: name,
style: {margin: '0 0 4px 6px'}
});
// return the panel
return ui.Panel({
widgets: [colorBox, description],
layout: ui.Panel.Layout.Flow('horizontal')
});
};
// Palette with the colors
// name of the legend
var names=['Corn', 'Cotton', 'Rice', 'Sorghum', 'Soybeans', 'Sunflower', 'Peanuts', 'Durum Wheat', 'Winter Wheat', 'Rye', 'Oats', 'Alfalfa', 'Sugarbeets', 'Dry Beans', 'Potatoes', 'Sugarcane', 'Misc Vegs & Fruits', 'Peas', 'Apples', 'Citrus', 'Almonds', 'Oranges'];
var palette=['FFD300', 'FF2626', '00A8E2', 'FF9E0A', '267000', 'FFFF00', '70A500', '896054', 'A57000', 'AA007C', 'A05989', 'FFA5E2', 'A800E2', 'A50000', '702600', 'AF7CFF', 'FF6666', '54FF00', 'BA004F', 'FFFF7C', '00A582', 'E27026'];
// Add color and and names
for (var i = 0; i < 22; i++) {
legend.add(makeRow(palette[i], names[i]));
}
Panel.add(legend)
//ui.root.insert(0, titlePanel);
// MAP LAYER MANAGER
//print(istate[key][10]);
var img1check=ui.Checkbox({
label: 'Toggle CSB layer',
value: true,
style: { backgroundColor: "00000000"
}
})
img1check.onChange(function(checked) {
// Shows or hides the first map layer based on the checkbox's value.
mapPanel.layers().get(1).setShown(checked);
});
var image1Label = ui.Label({
value: "2022 CSB Polygons",
style: { fontSize: '1.5em', fontWeight: 'bold', backgroundColor: "00000000"}
});
var query1Panel = ui.Panel({
widgets: [img1check],
style: { backgroundColor: "00000000"}
})
var image1Panel = ui.Panel({
widgets:[image1Label,query1Panel],
style: {position: 'top-left'}
})
var insetPanel = ui.Panel({
widgets:[insetmap],
style: {position: 'top-right'}
})
mapPanel.widgets().reset([image1Panel, insetPanel])
/*---Introduction Popup ---*/
var introlabel1 = ui.Label({
value: 'The Crop Sequence Boundaries are a geospatial data product representing non-confidential single crop field boundaries. The field polygons contain information on crop boundaries, crop rotation history, and area metrics like acreage and location in an eight-year time frame. Data derived from CSBs are from satellite imagery and publicly available data.',
style: {maxWidth:'400px'}
});
var introlabel2 = ui.Label({
value:'To use this application:',
style: {maxWidth:'400px'}
});
var introlabel3 = ui.Label({
value:
'1. Select a state and county of interest.',
style: {maxWidth:'350px', position:'top-right'}
});
var introlabel4 = ui.Label({
value:
'2. Click on a CSB polygon to summarize the CDL-derived crop history and size of that polygon.',
style: {maxWidth:'350px', position:'top-right'}
});
var introlabel5 = ui.Label({
value:
'For more details about this data or to download, please visit:',
style: {maxWidth:'400px'}
});
var link = ui.Label('USDA NASS/ERS Crop Sequence Boundaries', {color: 'blue'},'https://www.nass.usda.gov/Research_and_Science/Crop-Sequence-Boundaries/');
// Create a button to unhide the panel.
var intropanel = ui.Panel({
style: {
position: 'middle-left',
width: '450px',
height: '400px'
},
widgets: [
introlabel1, introlabel2, introlabel3, introlabel4, introlabel5, link
]
});
var closebutton = ui.Button({
label: 'Close',
onClick: function() {
// Display the panel.
intropanel.style().set('shown', false);
// Temporarily make a map click hide the panel
// and show the button.
var listenerId = mapPanel.onClick(function() {
intropanel.style().set('shown', false);
// Once the panel is hidden, the map should not
// try to close it by listening for clicks.
mapPanel.unlisten(listenerId);
});
}
});
mapPanel.add(intropanel);//
intropanel.add(closebutton)
/*---------------------------Define CSB Styling ---------------------------------*/
var styling_csb = {color: '101010', fillColor: '00000000', width: 1};
var cdlpalette = ['ffd300', 'ff2626', '00a8e2', 'ff9e0a', '267000', 'ffff00', 'ffffff', 'ffffff', 'ffffff', '70a500', '00af49', 'dda50a', 'dda50a', '7cd3ff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'e2007c', '896054', 'd8b56b', 'a57000', 'd69ebc', '707000', 'aa007c', 'a05989', '700049', 'd69ebc', 'd1ff00', '7c99ff', 'd6d600', 'd1ff00', '00af49', 'ffa5e2', 'a5f28c', '00af49', 'd69ebc', 'ffffff', 'a800e2', 'a50000', '702600', '00af49', 'af7cff', '702600', 'ff6666', 'ff6666', 'ffcc66', 'ff6666', '00af49', '00ddaf', '54ff00', 'f2a377', 'ff6666', '00af49', '7cd3ff', 'e8bfff', 'afffdd', '00af49', 'bfbf77', 'ffffff', '93cc93', 'c6d69e', 'ccbfa3', 'ff00ff', 'ff8eaa', 'ba004f', '704489', '7777', 'af9970', 'ffff7c', 'ffffff', 'b5705b', '00a582', 'e8d6af', 'af9970', 'ffffff', 'ffffff', 'ffffff', 'f2f2f2', '999999', '4970a3', 'ffffff', 'ffffff', 'ffffff', '7cafaf', 'e8ffbf', 'ffffff', 'ffffff', 'ffffff', '00ffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', '4970a3', 'd3e2f9', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', '999999', '999999', '999999', '999999', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ccbfa3', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', '93cc93', '93cc93', '93cc93', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'c6d69e', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'e8ffbf', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', '7cafaf', 'ffffff', 'ffffff', 'ffffff', 'ffffff', '7cafaf', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', 'ffffff', '00ff8c', 'd69ebc', 'ff6666', 'ff6666', 'ff6666', 'ff6666', 'ff8eaa', '334933', 'e27026', 'ff6666', 'ff6666', '739755', 'ff6666', 'af9970', 'ff8eaa', 'ff6666', 'ff8eaa', 'ff6666', 'ff6666', 'ff8eaa', '00af49', 'ffd300', 'ffd300', 'ff6666', 'f8d248', 'ff6666', '896054', 'ff6666', 'ff2626', 'e2007c', 'ff9e0a', 'ff9e0a', 'a57000', 'ffd300', 'a57000', '267000', '267000', 'ffd300', '000099', 'ff6666', 'ff6666', 'ff6666', 'ff6666', 'ff6666', 'ff6666', 'ff6666', 'ff6666', 'ffffff', 'ffffff', 'ffffff', '267000']
/*----------------------------Define dropdown functionality-------------------------*/
dropdown_menu_states.onChange(function(key) {
state_name = dropdown_menu_states.getValue();
print('State name', state_name);
layers.remove(state_outline_lyr);
layers.remove(county_outline_lyr);
insetlayers.remove(inset_county_outline_lyr);
layers.remove(csblayer);
//layers.remove(click_point);
analysisPanel.clear();
if (state_name === ' ') {
} else {
/*state_selected = us_states.filterMetadata('NAME', 'equals', state_name);*/
state_selected = us_states.filterMetadata('STATEFP', 'equals', istate[key][10]);
var polygonCentroid = state_selected.geometry().centroid({'maxError': 1});
mapPanel.setCenter(polygonCentroid.coordinates().get(0).getInfo(),
polygonCentroid.coordinates().get(1).getInfo(), 7);
var state_outline = empty.paint({featureCollection: state_selected, color: 1, width: 3})
.visualize({palette: 'cyan'});
state_outline_lyr = ui.Map.Layer(state_outline).setName(state_name);
//layers.add(state_outline_lyr);
layers.set(0, state_outline_lyr);
/*try to add CSB file here*/
/*var csb22 = istate[key][0];*/
csb22 = istate[key][0]
image1 = csb22;
empty1 = ee.Image().byte();
fills1 = empty1.paint({
featureCollection: csb22,
color: istate[key][3]
});
filledOutlines1 = empty1.paint(csb22, istate[key][1]).paint(csb22, 0, 1);
empty2 = ee.Image().byte();
fills2 = empty2.paint({
featureCollection: csb22,
color: istate[key][2]
});
var statefp_list = state_selected.reduceColumns(ee.Reducer.toList(), ['STATEFP']).get('list');
print('statefp_list', statefp_list);
state_FP_selected = ee.List(statefp_list).get(0);
print('STATEFP', state_FP_selected);
shp_us_counties = counties.filter(ee.Filter.eq('STATEFP', state_FP_selected));
var countyNames = shp_us_counties.reduceColumns(ee.Reducer.toList(), ['NAME']).get('list');
countyNames = ee.List(countyNames).sort();
countyNames = countyNames.insert(0, ' ');
print('Counties in this state', countyNames);
countyNames.evaluate(function(county){
dropdown_menu_counties.items().reset(county);
});
//mapPanel.widgets().reset([image1Panel, insetPanel]);
/*On click Functionality*/
mapPanel.onClick(function(coords) {
// Create or update the location label (the second widget in the panel)
/*var istatenum = dropdown_menu_states.getValue([0]);*/
var location = 'lon: ' + coords.lon.toFixed(4) + ' ' +
'lat: ' + coords.lat.toFixed(4);
var click_point = ee.Geometry.Point(coords.lon, coords.lat);
// var currentvalue = image1.reduceColumns(click_point);
//var currentyr = 'Crop Type: ' + currentvalue.get(istate[key][1]);
var ROI= image1.filterBounds(click_point);
var csbacres = "CSB Acres: "+ROI.aggregate_array(istate[key][11]).getInfo();
var currentyr = istate[key][9]+": "+ROI.aggregate_array(istate[key][12]).getInfo();
var prevyr1 = istate[key][9]-1+": "+ROI.aggregate_array(istate[key][13]).getInfo();
var prevyr2 = istate[key][9]-2+": "+ROI.aggregate_array(istate[key][14]).getInfo();
var prevyr3 = istate[key][9]-3+": "+ROI.aggregate_array(istate[key][15]).getInfo();
var prevyr4 =istate[key][9]-4+": "+ ROI.aggregate_array(istate[key][16]).getInfo();
var prevyr5 =istate[key][9]-5+": "+ ROI.aggregate_array(istate[key][17]).getInfo();
var prevyr6 =istate[key][9]-6+": "+ ROI.aggregate_array(istate[key][18]).getInfo();
var prevyr7 =istate[key][9]-7+": "+ ROI.aggregate_array(istate[key][19]).getInfo();
/*var info = ui.Label({value: 'Click on a feature', style: {whiteSpace: 'pre'}});*/
/*analysisPanel.widgets().set(0, ui.Label(istatenum));*/
analysisPanel.widgets().set(0, ui.Label(location));
analysisPanel.widgets().set(1, ui.Label(csbacres));
analysisPanel.widgets().set(2, ui.Label(currentyr));
analysisPanel.widgets().set(3, ui.Label(prevyr1));
analysisPanel.widgets().set(4, ui.Label(prevyr2));
analysisPanel.widgets().set(5, ui.Label(prevyr3));
analysisPanel.widgets().set(6, ui.Label(prevyr4));
analysisPanel.widgets().set(7, ui.Label(prevyr5));
analysisPanel.widgets().set(8, ui.Label(prevyr6));
analysisPanel.widgets().set(9, ui.Label(prevyr7));
//Add a blue dot to the map where the user clicked.
mapPanel.layers().set(3, ui.Map.Layer(click_point, {color: 'blue'}));
//layers.add(click_point);
});
/*
var createInset = function() {
var bounds = ee.Geometry.Rectangle(mapPanel.getBounds());
//var reticleMarker = ee.Geometry.Point(coords.lon, coords.lat);
insetmap.centerObject(bounds);
insetmap.clear();
//insetmap.addLayer(bounds);
//insetmap.addLayer(cnty.style(styling_co), {}, 'County Boundaries');
var rectangleCentroid = bounds.centroid({'maxError': 1});
insetmap.addLayer(rectangleCentroid,
{'color': 'red'},
'Result [red]: rectangle.centroid');
};
// Run it once to initialize.
createInset();
// Get a new inset map whenever you click on the big map.
mapPanel.onClick(createInset);
*/
if (state_selected !== null) {
}
}
});
dropdown_menu_counties.onChange(function(key) {
county_name = dropdown_menu_counties.getValue();
print('County name', county_name);
layers.remove(county_outline_lyr);
layers.remove(csblayer);
insetlayers.remove(inset_county_outline_lyr)
//layers.remove(click_point);
analysisPanel.clear();
if (county_name === ' ') {
AOI = state_selected;
} else {
county_selected = counties.filterMetadata('STATEFP', 'equals', state_FP_selected)
.filterMetadata('NAME', 'equals', county_name);
AOI = county_selected;
var polygonCentroid = county_selected.geometry().centroid({'maxError': 1});
mapPanel.setCenter(polygonCentroid.coordinates().get(0).getInfo(),
polygonCentroid.coordinates().get(1).getInfo(), 12);
var county_outline = empty.paint({featureCollection: county_selected, color: 1, width: 3})
.visualize({palette: 'cyan'});
county_outline_lyr = ui.Map.Layer(county_outline).setName(county_name);
inset_county_outline_lyr = ui.Map.Layer(county_outline).setName(county_name);
/*TRY Adding CSB here*/
var finalcsb=csb22;
var finalempty1 = empty1;
var finalfills1 = fills1;
var finalfilledOutlines1 = filledOutlines1;
var finalempty2 = empty2;
var finalfills2 = fills2;
/*var image1 = csb22;*/
csblayer = ui.Map.Layer(finalfilledOutlines1, {palette: ['000000'].concat(cdlpalette), min:0, max: 254}, '2021 CSB')
//layers.add(csblayer);
//layers.add(county_outline_lyr);
insetlayers.set(1, inset_county_outline_lyr);
layers.set(1, csblayer);
layers.set(2, county_outline_lyr);
if (county_selected !== null) {
}
}
});
ui.root.clear();
ui.root.add(ui.SplitPanel(Panel, mapPanel));
代码链接Sample code: https://code.earthengine.google.com/?scriptPath=users/sat-io/awesome-gee-catalog-examples:agriculture-vegetation-forestry/USDA-CSB-APP
App code: You can find the app here
License and Liability¶
The USDA NASS Crop Sequence Boundaries and the data offered at https://www.nass.usda.gov/Research_and_Science/Crop-Sequence-Boundaries are provided to the public as is and are considered public domain and free to redistribute. Users of the Crop Sequence Boundaries (CSB) are solely responsible for interpretations made from these products. The CSB are provided 'as is' and the USDA NASS does not warrant results you may obtain using the data. Contact our staff at (SM.NASS.RDD.GIB@usda.gov) if technical questions arise.
Created by: USDA NASS, USDA ERS
Curated in GEE by : USDA NASS, USDA ERS, Samapriya Roy
keywords: agricultural lands, USDA, crop layer, CDL, crop sequence boundary
华为开发者空间发布
让每位开发者拥有一台云主机
- 点赞
- 收藏
- 关注作者
评论(0)