Skip to content

Instantly share code, notes, and snippets.

@nickumia-reisys
Last active August 18, 2022 03:02
Show Gist options
  • Save nickumia-reisys/a3c54ecbc192f079400bf5b01d3ad746 to your computer and use it in GitHub Desktop.
Save nickumia-reisys/a3c54ecbc192f079400bf5b01d3ad746 to your computer and use it in GitHub Desktop.
Maybe I'll update this description when I'm less tired :(
import json, sys
json_build = {}
with open('summary', 'r') as summ:
items = summ.readlines()
for i in items:
title = i.split(']')[0].split('[')[-1]
link = i.split('](#')[1].split(')')[0]
description = i.split('):')[-1]
json_build[title] = {
'title': title,
'link': link,
'description': description
}
with open('modal', 'r')as moda:
items = moda.readlines()
def group_sections(lines):
groups = {}
i = 0
groups[i] = []
for l in lines:
if l != '\n':
groups[i].append(l)
else:
i += 1
groups[i] = []
for g in groups.keys():
groups[g] = ''.join(groups[g])
return groups
for i,j in group_sections(items).items():
name = 'unknown'
sponsor = 'unknown'
url = 'unknown'
summary = 'unknown'
howitworks = ''
app = ''
preview = None
if '####' in j:
name = j.split('#### ')[-1].split('\n')[0]
if '**Sponsor:**' in j:
sponsor = j.split('**Sponsor:** ')[-1].split('\n')[0]
if '**URL:**' in j:
url = j.split('**URL:** ')[-1].split('\n')[0].split('<')[-1].split('>')[0]
if '**Summary:**' in j:
summary = j.split('**Summary:** ')[-1].split('\n')[0]
if '**How it works:**' in j:
howitworks = j.split('**How it works:** ')[-1].split('\n')[0]
if '**Application:**' in j:
app = j.split('**Application:** ')[-1].split('\n')[0]
if '**Preview:**' in j:
preview = j.split('**Preview:** ')[-1].split('\n')[0].split('[](')[-1].split(')')[0]
if name in json_build.keys():
json_build[name]['sponsor'] = sponsor
json_build[name]['url'] = url
json_build[name]['summary'] = summary
json_build[name]['howitworks'] = howitworks
json_build[name]['application'] = app
json_build[name]['preview'] = preview
with open(sys.argv[1], 'w') as jso:
jso.write(json.dumps(json_build, indent=2))
#### Crop Explorer
**Sponsor:** USDA
**Name:** Crop Explorer
**URL:** <http://www.pecad.fas.usda.gov/cropexplorer/Default.aspx>
**Summary:** Crop Explorer provides near real-time information on crops and conditions by region, satellite images, live data and maps, with links to production estimates, area, yield, and crop assessments.
**How it works:** Crop Explorer provides users with agricultural analysis information using satellite imagery and ancillary information quickly and cost effectively. Crop Explorer automates the processing and extraction of certain agro-meteorological indicators from source data. Information is presented using thematic maps and time series charts for weather, crop model, soil moisture and vegetation indices.
**Application:** U.S. and international producers, traders, researchers, and the public can access remote sensing information used by agricultural economists and scientists who predict crop production worldwide.
**Preview:** [![](https://s3-us-gov-west-1.amazonaws.com/cg-0817d6e3-93c4-4de8-8b32-da6919464e61/CropExplorer_preview.png)](http://www.pecad.fas.usda.gov/cropexplorer/Default.aspx)
#### CropScape – Cropland Data Layer
**Sponsor:** USDA
**Name:** CropScape – Cropland Data Layer
**URL:** <http://nassgeodata.gmu.edu/CropScape/>
**Summary:** CropScape is a web-based interactive map visualization, dissemination, and querying system for U.S. cropland. Capabilities include on-line geospatial crop information access, geospatial query and on-line analytics via interactive maps.
**How it works:** CropScape provides a crop-specific land cover data layer that is created annually for the continental United States using moderate resolution satellite imagery and extensive agricultural ground truth.
**Application:** CropScape provides easier access to geospatial products for exploring croplands. It delivers data visualization tools directly into the hands of the agricultural community without the need for specialized expertise, GIS software, or high-end computers.
**Preview:** [![](https://s3-us-gov-west-1.amazonaws.com/cg-0817d6e3-93c4-4de8-8b32-da6919464e61/CropScape_preview.png)](http://nassgeodata.gmu.edu/CropScape/)
* [Crop Explorer](#crop-explorer): Provides access to imagery and modeled estimates of crop production, soil moisture, and weather for the US and globally.
* [CropScape – Cropland Data Layer](#cropscape-cropland-data-layer): Provides crop-specific land cover data layer created annually for the continental United States using moderate resolution satellite imagery and extensive agricultural ground truth.
@nickumia-reisys
Copy link
Author

Example usage: python md2json.py _data/foodresilience-tools.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment