|
31 | 31 |
|
32 | 32 | outfile = open(args.output,'w') |
33 | 33 | writer = csv.writer(outfile) |
34 | | - writer.writerow(['lat','lon','name','doi']) |
| 34 | + writer.writerow(['wkt','name','year','doi']) |
35 | 35 |
|
36 | 36 | for h in hits['hits']['hits']: |
37 | 37 | metadata = decustomize_schema(h['metadata']) |
38 | 38 | if 'geoLocations' in metadata: |
| 39 | + doi = 'https://doi.org/'+metadata['identifier']['identifier'] |
| 40 | + title=metadata['titles'][0]['title'].split(':')[0] |
39 | 41 | geo = metadata['geoLocations'] |
| 42 | + year = metadata['publicationYear'] |
40 | 43 | for g in geo: |
41 | | - #if 'geoLocationBox' in g: |
42 | | - # box = g['geoLocationBox'] |
43 | | - # lat=[box['northBoundLatitude'],box['northBoundLatitude'],box['southBoundLatitude'],box['southBoundLatitude']] |
44 | | - # lon=[box['eastBoundLongitude'],box['westBoundLongitude'],box['eastBoundLongitude'],box['westBoundLongitude']] |
45 | | - # tlon,tlat = transform(from_proj,to_proj,lon,lat) |
46 | | - # pt_lat=pt_lat+tlat |
47 | | - # pt_lon= pt_lon+tlon |
48 | | - # cen = metadata['publicationYear'][1] |
49 | | - # dec = metadata['publicationYear'][2] |
50 | | - # identifier.append(metadata['identifier']['identifier']) |
51 | | - # author.append(metadata['creators'][0]['creatorName']) |
52 | | - # title.append(metadata['titles'][0]['title'].split(':')[0]) |
53 | | - # year.append(metadata['publicationYear']) |
54 | | - # color.append(clo) |
55 | | - # x0 = x0 + [tlon[0],tlon[2],tlon[0],tlon[1]] |
56 | | - # x1 = x1 + [tlon[1],tlon[3],tlon[2],tlon[3]] |
57 | | - # y0 = y0 + [tlat[0],tlat[2],tlat[0],tlat[1]] |
58 | | - # y1 = y1 + [tlat[1],tlat[3],tlat[2],tlat[3]] |
| 44 | + if 'geoLocationBox' in g: |
| 45 | + box = g['geoLocationBox'] |
| 46 | + p1 = f"{box['eastBoundLongitude']} {box['northBoundLatitude']}" |
| 47 | + p2 = f"{box['westBoundLongitude']} {box['northBoundLatitude']}" |
| 48 | + p3 = f"{box['westBoundLongitude']} {box['southBoundLatitude']}" |
| 49 | + p4 = f"{box['eastBoundLongitude']} {box['southBoundLatitude']}" |
| 50 | + wkt = f'POLYGON (({p1}, {p2}, {p3}, {p4}, {p1}))' |
| 51 | + writer.writerow([wkt,title,year,doi]) |
| 52 | + |
59 | 53 | if 'geoLocationPoint' in g: |
60 | 54 | point = g['geoLocationPoint'] |
61 | | - #tlon,tlat =\ |
62 | | - #transform(from_proj,to_proj,point['pointLongitude'],point['pointLatitude']) |
63 | | - #pt_lat=pt_lat+[tlat] |
64 | | - #pt_lon= pt_lon+[tlon] |
65 | | - doi = 'https://doi.org/'+metadata['identifier']['identifier'] |
66 | | - #author=author+[metadata['creators'][0]['creatorName']] |
67 | | - title=metadata['titles'][0]['title'].split(':')[0] |
68 | | - lat = point['pointLatitude'] |
69 | | - lon = point['pointLongitude'] |
70 | | - writer.writerow([lat,lon,title,doi]) |
71 | | - #year = year+[metadata['publicationYear']] |
72 | | - #cen = metadata['publicationYear'][1] |
73 | | - #dec = metadata['publicationYear'][2] |
| 55 | + wkt = f"POINT ({point['pointLongitude']} {point['pointLatitude']})" |
| 56 | + writer.writerow([wkt,title,year,doi]) |
74 | 57 |
|
0 commit comments